Part Number Hot Search : 
C100M MR5002 T346004 S2110 SC2383 MIC4452 SI4936DY 0M10X20
Product Description
Full Text Search
 

To Download ATSAMD20E17 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  atmel-42129k?sam-d20_datasheet?06/2014 smart description the atmel ? | smart ? sam d20 is a series of low-powe r microcontrollers using the 32-bit arm ? cortex ? -m0+ processor, and ranging from 32- to 64-pins with up to 256kb flash and 32kb of sram. the sam d20 devices operate at a maximum frequency of 48mhz and reach 2.14 coremark/mhz. they are designed for simple and intuitive migration with identical peripheral modules, hex compatible code, identical linear address map and pin compatible migration paths between all devices in the product series. all devices include intelligent and flexible peripherals, atmel event system for inter-peripheral signaling, and support for capacitive touch button, slider and wheel user interfaces. the atmel | smart sam d20 devices prov ide the following f eatures: in-system programmable flash, eight-cha nnel event system, programmable interrupt controller, up to 52 programmable i/o pins, 32-bit real-time clock and calendar, up to eight 16-bit timer/counters (tc). the timer/counters ca n be configured to perform frequency and waveform generation, program execution timi ng or input capture with time and frequency measurement of digital signals. the tcs can ope rate in 8- or 16-bit mode, or be cascaded to form a 32-bit tc. the series provide up to six serial communication modules (sercom) that each can be configured to act as an usart, uart, spi and i 2 c up to 400khz; up to twenty-channel 350ksps 12-bit adc with programmable gain and optional oversampling and decimation supporting up to 16-bit resoluti on, one 10-bit 350ksps dac, two analog comparators with window mode, peripheral touc h controller supporting up to 256 buttons, sliders, wheels, and proximity sensing; prog rammable watchdog timer, brown-out detector and power-on reset, and two-pin serial wire debug (swd) program and debug interface. all devices have accurate and low-power external and internal oscillators. all oscillators can be used as a source for the system clock. different clock domains can be independently configured to run at different frequencies while enabling power saving by running each peripheral at its optimal clock frequency. the atmel | smart sam d20 devices have two software-selectable sleep modes, idle and standby. in idle mode the cpu is stopped while all other functions can be kept running. in standby all clocks and functions are stopped ex pect those selected to continue running. the device supports sleepwalking. this feature allows the peripheral to wake up from sleep based on predefined conditions, and thus a llows the cpu to wake up only when needed, e.g. when a threshold is crossed or a re sult is ready. the event system supports synchronous and asynchronous events, allowing peripherals to receive, react to and send events even in standby mode. the flash program memory can be reprogra mmed in-system through the swd interface. the same interface can be used for non-intrus ive on-chip debug of application code. a boot loader running in the device can use any comm unication interface to download and upgrade the application program in the flash memory. the atmel | smart sam d20 devices are supported with a full suite of program and system development tools, including c compilers, macro assemblers, program debugger/simulators, programmers and evaluation kits . atmel sam d20j / sam d20g / sam d20e smart arm-based microcontroller datasheet
2 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 features z processor z arm cortex-m0+ cpu running at up to 48mhz z single-cycle hardware multiplier z memories z 16/32/64/128/256kb in-system self-programmable flash z 2/4/8/16/32kb sram z system z power-on reset (por) and brown-out detection (bod) z internal and external clock options with 48mhz digital frequency locked loop (dfll48m) z external interrupt controller (eic) z 16 external interrupts z one non-maskable interrupt z two-pin serial wire debug (swd) programming, test and debugging interface z low power z idle and standby sleep modes z sleepwalking peripherals z peripherals z 8-channel event system z up to eight 16-bit timer/counters (tc), configurable as either: z one 16-bit tc with co mpare/capture channels z one 8-bit tc with compare/capture channels z one 32-bit tc with compare/capt ure channels, by using two tcs z 32-bit real time counter (rtc) with clock/calendar function z watchdog timer (wdt) z crc-32 generator z up to six serial communication interfaces (sercom), each configurable to operate as either: z usart with full-duplex and singl e-wire half-duplex configuration z i 2 c up to 400khz z spi z one 12-bit, 350ksps analog-to-digital converter (adc) with up to 20 channels z differential and single-ended channels z 1/2x to 16x gain stage z automatic offset and gain error compensation z oversampling and decimation in hardware to support 13-, 14-, 15- or 16-bit resolution z 10-bit, 350ksps digital-to-analog converter (dac) z two analog comparators with window compare function z peripheral touch controller (ptc) z 256-channel capacitive touch and proximity sensing z i/o z up to 52 programmable i/o pins z packages z 64-pin tqfp, qfn z 48-pin tqfp, qfn z 32-pin tqfp, qfn z operating voltage z 1.62v ? 3.63v z power consumption z down to 70a/mhz in active mode z down to 8a running the peripheral touch controller
3 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1. configuration summary sam d20j sam d20g sam d20e number of pins 64 48 32 general purpose i/o-pins (gpios) 52 38 26 flash 256/128/64/32/16kb 256/128/64/32/16kb 256/128/64/32/16kb sram 32/16/8/4/2kb 32/16/8/4/2kb 32/16/8/4/2kb maximum cpu frequency 48mhz event system channels 8 8 8 timer counter (tc) 8 6 6 waveform output channels for tc 2 2 2 serial communication interface (sercom) 6 6 4 analog-to-digital converter (adc) channels 20 14 10 analog comparators 2 2 2 digital-to-analog converter (dac) channels 1 1 1 real-time counter (rtc) yes yes yes rtc alarms 1 1 1 rtc compare values 1 32-bit value or 2 16-bit values 1 32-bit value or 2 16-bit values 1 32-bit value or 2 16-bit values external interrupt lines 16 16 16 peripheral touch controller (ptc) x and y lines 16x16 12x10 10x6 packages qfn tqfp qfn tqfp qfn tqfp oscillators 32.768khz crystal oscillator (xosc32k) 0.4-32mhz crystal oscillator (xosc) 32.768khzinternal oscillator (osc32k) 32khz ultra-low-power internal oscillator (osculp32k) 8mhz high-accuracy internal oscillator (osc8m) 48mhz digital frequency locked loop (dfll48m) sw debug interface yes yes yes watchdog timer (wdt) yes yes yes
4 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 2. ordering information 2.1 sam d20e samd 20 e 14 a - m u t product family samd = general purpose microcontroller 20 = cortex m0+ cpu, basic feature set e = 32 pins g = 48 pins j = 64 pins no character = tray (default) t = tape and reel u = 40 - 85 o c matte sn plating h = 40 - 85 o c nipdau plating a = tqfp m = qfn c = ubga u = wlcsp product series flash memory density device variant a = default variant pin count package carrier package grade package type 18 = 256kb 17 = 128kb 16 = 64kb 15 = 32kb 14 = 16kb ordering code flash (bytes) sram (bytes) package carrier type atsamd20e14a-au 16k 2k tqfp32 tray atsamd20e14a-aut ta p e & r e e l atsamd20e14a-mu qfn32 tray atsamd20e14a-mut ta p e & r e e l atsamd20e15a-au 32k 4k tqfp32 tray atsamd20e15a-aut ta p e & r e e l atsamd20e15a-mu qfn32 tray atsamd20e15a-mut ta p e & r e e l atsamd20e16a-au 64k 8k tqfp32 tray atsamd20e16a-aut ta p e & r e e l atsamd20e16a-mu qfn32 tray atsamd20e16a-mut ta p e & r e e l
5 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 2.2 sam d20g ATSAMD20E17a-au 128k 16k tqfp32 tray ATSAMD20E17a-aut ta p e & r e e l ATSAMD20E17a-mu qfn32 tray ATSAMD20E17a-mut ta p e & r e e l atsamd20e18a-au 256k 32k tqfp32 tray atsamd20e18a-aut ta p e & r e e l atsamd20e18a-mu qfn32 tray atsamd20e18a-mut ta p e & r e e l ordering code flash (bytes) sram (bytes) package carrier type ordering code flash (bytes) sram (bytes) package carrier type atsamd20g14a-au 16k 2k tqfp48 tray atsamd20g14a-aut ta p e & r e e l atsamd20g14a-mu qfn48 tray atsamd20g14a-mut ta p e & r e e l atsamd20g15a-au 32k 4k tqfp48 tray atsamd20g15a-aut ta p e & r e e l atsamd20g15a-mu qfn48 tray atsamd20g15a-mut ta p e & r e e l atsamd20g16a-au 64k 8k tqfp48 tray atsamd20g16a-aut ta p e & r e e l atsamd20g16a-mu qfn48 tray atsamd20g16a-mut ta p e & r e e l atsamd20g17a-au 128k 16k tqfp48 tray atsamd20g17a-aut ta p e & r e e l atsamd20g17a-mu qfn48 tray atsamd20g17a-mut ta p e & r e e l atsamd20g18a-au 256k 32k tqfp48 tray atsamd20g18a-aut ta p e & r e e l atsamd20g18a-mu qfn48 tray atsamd20g18a-mut ta p e & r e e l
6 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 2.3 sam d20j ordering code flash (bytes) sram (bytes) package carrier type atsamd20j14a-au 16k 2k tqfp64 tray atsamd20j14a-aut ta p e & r e e l atsamd20j14a-mu qfn64 tray atsamd20j14a-mut ta p e & r e e l atsamd20j15a-au 32k 4k tqfp64 tray atsamd20j15a-aut ta p e & r e e l atsamd20j15a-mu qfn64 tray atsamd20j15a-mut ta p e & r e e l atsamd20j16a-au 64k 8k tqfp64 tray atsamd20j16a-aut ta p e & r e e l atsamd20j16a-mu qfn64 tray atsamd20j16a-mut ta p e & r e e l atsamd20j17a-au 128k 16k tqfp64 tray atsamd20j17a-aut ta p e & r e e l atsamd20j17a-mu qfn64 tray atsamd20j17a-mut ta p e & r e e l atsamd20j18a-au 256k 32k tqfp64 tray atsamd20j18a-aut ta p e & r e e l atsamd20j18a-mu qfn64 tray atsamd20j18a-mut ta p e & r e e l
7 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 3. block diagram notes: 1. some products have different number of sercom instances, ti mer/counter instances, ptc signals and adc signals. refer to ?configuration summary? on page 3 for details. 6 x sercom 8 x timer counter real time counter ahb-apb bridge c m s high speed bus matrix port port watchdog timer serial wire swdio nvm controller 256/128/64/32/16kb flash s arm cortex-m0+ processor f max 48mhz swclk device service unit ahb-apb bridge a adc ain[19:0] vrefa ain[3:0] s 32/16/8/4/2kb ram m reset controller sleep controller clock controller power manager reset 8 x timer counter event system s 6 x sercom 2 analog comparators system controller xout xin xout32 xin32 osculp32k osc32k osc8m dfll48m bod33 xosc32k xosc vref generic clock x[15:0] y[15:0] peripheral touch controller peripheral access controller ahb-apb bridge b vrefa vout dac external interrupt controller peripheral access controller peripheral access controller extint[15:0] nmi gclk_io[7:0] s pin[3:0] wo[1:0] vrefb (see note1) cmp1:0] arm single cycle iobus controller
8 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 4. pinout 4.1 sam d20j pa00 1 pa01 2 pa02 3 pa03 4 pb04 5 pb05 6 gndana 7 vddana 8 pb06 9 pb07 10 pb08 11 pb09 12 pa04 13 pa05 14 pa06 15 pa07 16 pa08 17 pa09 18 pa10 19 pa11 20 vddio 21 gnd 22 pb10 23 pb11 24 pb12 25 pb13 26 pb14 27 pb15 28 pa12 29 pa13 30 pa14 31 pa15 32 vddio 48 gnd 47 pa25 46 pa24 45 pa23 44 pa22 43 pa21 42 pa20 41 pb17 40 pb16 39 pa19 38 pa18 37 pa17 36 pa16 35 vddio 34 gnd 33 pb22 49 pb23 50 pa27 51 reset 52 pa28 53 gnd 54 vddcore 55 vddin 56 pa30 57 pa31 58 pb30 59 pb31 60 pb00 61 pb01 62 pb02 63 pb03 64 digital pin analog pin oscillator ground input supply regulated output supply reset pin
9 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 4.2 sam d20g pa21 pa00 1 pa01 2 pa02 3 pa03 4 gndana 5 vddana 6 pb08 7 pb09 8 pa04 9 pa05 10 pa06 11 pa07 12 pa08 13 pa09 14 pa10 15 pa11 16 vddio 17 gnd 18 pb10 19 pb11 20 pa12 21 pa13 22 pa14 23 pa15 24 vddio 36 gnd 35 pa25 34 pa24 33 pa23 32 pa22 31 30 pa20 29 pa19 28 pa18 27 pa17 26 pa16 25 pb22 37 pb23 38 pa27 39 reset 40 pa28 41 gnd 42 vddcore 43 vddin 44 pa30 45 pa31 46 pb02 47 pb03 48 digital pin analog pin oscillator ground input supply regulated output supply reset pin
10 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 4.3 sam d20e pa00 1 pa01 2 pa02 3 pa03 4 pa04 5 pa05 6 pa06 7 pa07 8 vddana 9 gnd 10 pa08 11 pa09 12 pa10 13 pa11 14 pa14 15 pa15 16 pa25 24 pa24 23 pa23 22 pa22 21 pa19 20 pa18 19 pa17 18 pa16 17 pa27 25 reset 26 pa28 27 gnd 28 vddcore 29 vddin 30 pa30 31 pa31 32 digital pin analog pin oscillator ground input supply regulated output supply reset pin
11 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 5. i/o multiplexing and considerations 5.1 multiplexed signals each pin is by default controlled by the port as a general purpose i/o and alternatively it can be assigned to one of the peripheral functions a, b, c, d, e, f, g or h. to enable a peripheral function on a pin, the peripheral multiplexer enable bit in the pin configuration register corresponding to that pin (pincfgn.pmuxen, n = 0-31) in the port must be written to one. the selection of peripheral function a to h is done by writing to the peripheral multiplexing odd and even bits in the peripheral multiplexing register (p muxn.pmuxe/o) in the port. refer to ?port? on page 280 for details on how to configure the i/o multiplexing. table 5-1 describes the peripheral signals multiplexed to the port i/o pins. table 5-1. port function multiplexing pin i/o pin supply pin type a b (1) c d e f g h sam d20e sam d20g sam d20j eic ref adc ac ptc dac sercom (2) tc (3) ac/gclk 1 1 1 pa00 vddana extint[0] sercom1/ pad[0] tc2/ wo[0] 2 2 2 pa01 vddana extint[1] sercom1/ pad[1] tc2/ wo[1] 3 3 3 pa02 vddana extint[2] ain[0] y[0] vout 4 4 4 pa03 vddana extint[3] adc/vrefa dac/vrefa ain[1] y[1] 5 pb04 vddana extint[4] ain[12] y[10] 6 pb05 vddana extint[5] ain[13] y[11] 9 pb06 vddana extint[6] ain[14] y[12] 10 pb07 vddana extint[7] ain[15] y[13] 7 11 pb08 vddana extint[8] ain[2] y[14] sercom4/ pad[0] tc4/ wo[0] 8 12 pb09 vddana extint[9] ain[3] y[15] sercom4/ pad[1] tc4/ wo[1] 5 9 13 pa04 vddana extint[4] adc/ vrefb ain[4] ain[0] y[2] sercom0/ pad[0] tc0/ wo[0] 6 10 14 pa05 vddana extint[5] ain[5] ain[1] y[3] sercom0/ pad[1] tc0/ wo[1] 7 11 15 pa06 vddana extint[6] ain[6] ain[2] y[4] sercom0/ pad[2] tc1/ wo[0] 8 12 16 pa07 vddana extint[7] ain[7] ain[3] y[5] sercom0/ pad[3] tc1/ wo[1] 11 13 17 pa08 vddio i 2 c nmi ain[16] x[0] sercom0/ pad[0] sercom2/ pad[0] tc0/ wo[0] 12 14 18 pa09 vddio i 2 c extint[9] ain[17] x[1] sercom0/ pad[1] sercom2/ pad[1] tc0/ wo[1] 13 15 19 pa10 vddio extint[10] ain[18] x[2] sercom0/ pad[2] sercom2/ pad[2] tc1/ wo[0] gclk_o[4] 14 16 20 pa11 vddio extint[11] ain[19] x[3] sercom0/ pad[3] sercom2/ pad[3] tc1/ wo[1] gclk_io[5] 19 23 pb10 vddio extint[10] sercom4/ pad[2] tc5/ wo[0] gclk_io[4] 20 24 pb11 vddio extint[11] sercom4/ pad[3] tc5/ wo[1] gclk_io[5] 25 pb12 vddio i 2 c extint[12] x[12] sercom4/ pad[0] tc4/ wo[0] gclk_io[6] 26 pb13 vddio i 2 c extint[13] x[13] sercom4/ pad[1] tc4/ wo[1] gclk_io[7] 27 pb14 vddio extint[14] x[14] sercom4/ pad[2] tc5/ wo[0] gclk_io[0]
12 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 note: 1. all analog pin functions are on peripheral function b. peri pheral function b must be selected to disable the digital con trol of the pin. 28 pb15 vddio extint[15] x[15] sercom4/ pad[3] tc5/ wo[1] gclk_io[1] 21 29 pa12 vddio i 2 c extint[12] sercom2/ pad[0] sercom4/ pad[0] tc2/ wo[0] ac/cmp[0] 22 30 pa13 vddio i 2 c extint[13] sercom2/ pad[1] sercom4/ pad[1] tc2/ wo[1] ac/cmp[1] 15 23 31 pa14 vddio extint[14] sercom2/ pad[2] sercom4/ pad[2] tc3/ wo[0] gclk_io[0] 16 24 32 pa15 vddio extint[15] sercom2/ pad[3] sercom4/ pad[3] tc3/ wo[1] gclk_io[1] 17 25 35 pa16 vddio i 2 c extint[0] x[4] sercom1/ pad[0] sercom3/ pad[0] tc2/ wo[0] gclk_io[2] 18 26 36 pa17 vddio i 2 c extint[1] x[5] sercom1/ pad[1] sercom3/ pad[1] tc2/ wo[1] gclk_io[3] 19 27 37 pa18 vddio extint[2] x[6] sercom1/ pad[2] sercom3/ pad[2] tc3/ wo[0] ac/cmp[0] 20 28 38 pa19 vddio extint[3] x[7] sercom1/ pad[3] sercom3/ pad[3] tc3/ wo[1] ac/cmp[1] 39 pb16 vddio i 2 c extint[0] sercom5/ pad[0] tc6/ wo[0] gclk_io[2] 40 pb17 vddio i 2 c extint[1] sercom5/ pad[1] tc6/ wo[1] gclk_io[3] 29 41 pa20 vddio extint[4] x[8] sercom5/ pad[2] sercom3/ pad[2] tc7/ wo[0] gclk_io[4] 30 42 pa21 vddio extint[5] x[9] sercom5/ pad[3] sercom3/ pad[3] tc7/ wo[1] gclk_io[5] 21 31 43 pa22 vddio i 2 c extint[6] x[10] sercom3/ pad[0] sercom5/ pad[0] tc4/ wo[0] gclk_io[6] 22 32 44 pa23 vddio i 2 c extint[7] x[11] sercom3/ pad[1] sercom5/ pad[1] tc4/ wo[1] gclk_io[7] 23 33 45 pa24 vddio extint[12] sercom3/ pad[2] sercom5/ pad[2] tc5/ wo[0] 24 34 46 pa25 vddio extint[13] sercom3/ pad[3] sercom5/ pad[3] tc5/ wo[1] 37 49 pb22 vddio extint[6] sercom5/ pad[2] tc7/ wo[0] gclk_io[0] 38 50 pb23 vddio extint[7] sercom5/ pad[3] tc7/ wo[1] gclk_io[1] 25 39 51 pa27 vddio extint[15] gclk_io[0] 27 41 53 pa28 vddio extint[8] gclk_io[0] 31 45 57 pa30 vddio extint[10] sercom1/ pad[2] tc1/ wo[0] swclk gclk_io[0] 32 46 58 pa31 vddio extint[11] sercom1/ pad[3] tc1/ wo[1] swdio (4) 59 pb30 vddio i 2 c extint[14] sercom5/ pad[0] tc0/ wo[0] 60 pb31 vddio i 2 c extint[15] sercom5/ pad[1] tc0/ wo[1] 61 pb00 vddana extint[0] ain[8] y[6] sercom5/ pad[2] tc7/ wo[0] 62 pb01 vddana extint[1] ain[9] y[7] sercom5/ pad[3] tc7/ wo[1] 47 63 pb02 vddana extint[2] ain[10] y[8] sercom5/ pad[0] tc6/ wo[0] 48 64 pb03 vddana extint[3] ain[11] y[9] sercom5/ pad[1] tc6/ wo[1] table 5-1. port function multiplexing (continued) pin i/o pin supply pin type a b (1) c d e f g h sam d20e sam d20g sam d20j eic ref adc ac ptc dac sercom (2) tc (3) ac/gclk
13 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 2. only some pins can be used in sercom i 2 c mode. see the type column for using a sercom pin in i 2 c mode. refer to the ?i2c pins? on page 572 for details on the i 2 c pin characteristics 3. note that tc6 and tc7 are not supported on the sam d20g. refer to ?configuration summary? on page 3 for details. 4. this function is only activat ed in the presence of a debugger 5.2 other functions 5.2.1 oscillator pinout the oscillators are not mapped to the normal port functions and their multiplexing are controlled by registers in the system controller (sysctrl). refer to ?sysctrl ? system controller? on page 128 for more information. 5.2.2 serial wire debug interface pinout after reset, swclk functionality is selected for pin pa30 to allow for debugger probe detection. the application software can switch the swclk functionality of pa30 to gpio (or other peripherals) during runtime. pa31, by default, is config- ured like other normal i/o pins and will automatically swit ch to swdio function when a debugger cold-plugging or hot- plugging is detected. when the device is put in debug mode, application software accesses to pa30 and pa31 port registers are ignored. refer to ?dsu ? device service unit? on page 37 for more information. oscillator supply signal i/o pin xosc vddio xin pa14 xout pa15 xosc32k vddana xin32 pa00 xout32 pa01 signal supply i/o pin swclk vddio pa30 swdio vddio pa31
14 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 6. signal descriptions list the following table gives details on signal names classified by peripheral. signal name function type active level analog comparators - ac ain[3:0] ac analog inputs analog cmp[1:0] ac comparator outputs digital analog digital converter - adc ain[19:0] adc analog inputs analog vrefp adc voltage external reference analog digital analog converter - dac vout dac voltage output analog vrefp dac voltage external reference analog external interrupt controller extint[15:0] external interrupts input nmi external non-maskable interrupt input generic clock generator - gclk gclk_io[7:0] generic clock (source clock or generic clock generator output) i/o power manager - pm reset reset input low serial communication interface - sercomx pad[3:0] sercom i/o pads i/o system control - sysctrl xin crystal input analog/ digital xin32 32khz crystal input analog/ digital xout crystal output analog xout32 32khz crystal output analog timer counter - tcx wo[1:0] waveform outputs output peripheral touch controller - ptc x[15:0] ptc input analog y[15:0] ptc input analog general purpose i/o - port pa25 - pa00 parallel i/o controller i/o port a i/o
15 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 pa28 - pa27 parallel i/o controller i/o port a i/o pa31 - pa30 parallel i/o controller i/o port a i/o pb17 - pb00 parallel i/o controller i/o port b i/o pb23 - pb22 parallel i/o controller i/o port b i/o pb31 - pb30 parallel i/o controller i/o port b i/o signal name function type active level
16 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 7. power supply and start-up considerations 7.1 power domain overview 7.2 power supply considerations 7.2.1 power supplies the atmel ? sam d20 has several different power supply pins: z vddio: powers i/o lines, osc8m and xosc. voltage is 1.62v to 3.63v. z vddin: powers i/o lines and the internal regulator. voltage is 1.62v to 3.63v. z vddana: powers i/o lines and the adc, ac, dac, pt c, osculp32k, osc32k, xosc32k. voltage is 1.62v to 3.63v. z vddcore: internal regulated voltage output. powers the core, memories and peripherals. voltage is 1.2v. the same voltage must be applied to both vddin, vddio and vddana. this common voltage is referred to as v dd in the datasheet. the ground pins, gnd, are common to vddcore, vddi o and vddin. the ground pin for vddana is gndana. voltage regulator vddin vddcore gnd adc ac dac ptc xosc32k osc32k vddana gndana pa[7:2] pb[9:0] pa[1:0] digital logic (cpu, peripherals) dfll48m vddio osc8m xosc osculp32k pa[31:16] pb[31:10] pa[15:14] bod33 por pa[13:8] bod12
17 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 for decoupling recommendations for the different power supplies, refer to the schematic checklist. refer to ?schematic checklist? on page 608 for details. 7.2.2 voltage regulator the voltage regulator has two different modes: z normal mode: to be used when the cpu and peripherals are running z low power (lp) mode: to be used when the regulator draws small static current. it can be used in standby mode 7.2.3 typical powering schematics the sam d20 uses a single supply from 1.62v to 3.63v. the following figure shows the recommended power supply connection. figure 7-1. power supply connection 7.2.4 power-up sequence 7.2.4.1 minimum rise rate the integrated power-on reset (por) circuitry monitoring the vddana power supply requires a minimum rise rate. refer to the ?electrical characteristics? on page 563 for details. 7.2.4.2 maximum rise rate the rise rate of the power supply must not exceed the val ues described in electrical characteristics. refer to the ?electrical characteristics? on page 563 for details. (1.62v 3.63v) main supply vddio vddana vddin vddcore gnd gndana sam d20
18 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 7.3 power-up this section summarizes the power-up sequence of the sa m d20. the behavior after power-up is controlled by the power manager. refer to ?pm ? power manager? on page 101 for details. 7.3.1 starting of clocks after power-up, the device is set to its initial state and kept in reset, until the power has stabilized throughout the device. once the power has stabilized, the device will use a 1mhz clock. this clock is derived from the 8mhz internal oscillator (osc8m), which is divided by eight and used as a clock source for generic clock generator 0. generic clock generator 0 is the main clock for the power manager (pm). some synchronous system clocks are active, allowing software execution. refer to the ?clock mask register? section in ?pm ? power manager? on page 101 for the list of default peripheral clocks running. synchronous system clocks that are running are by default not divided and receive a 1mhz clock through generic clock generator 0. other generic clocks are disabled except gclk_wdt, which is used by the watchdog timer (wdt). 7.3.2 i/o pins after power-up, the i/o pins are tri-stated. 7.3.3 fetching of in itial instructions after reset has been released, the cpu starts fetching pc and sp values from the reset address, which is 0x00000000. this address points to the first executable address in the inter nal flash. the code read from the internal flash is free to configure the clock system and clock sources. refer to ?pm ? power manager? on page 101 , ?gclk ? generic clock controller? on page 79 and ?sysctrl ? system controller? on page 128 for details. refer to the arm architecture reference manual for more information on cpu startup ( http://www.arm.com ). 7.4 power-on reset a nd brown-out detector the sam d20 embeds three features to monitor, warn and/or reset the device: z por: power-on reset on vddana z bod33: brown-out detector on vddana z bod12: voltage regulator internal brown-out detector on vddcore. the voltage regulator internal bod is calibrated in production and its calibration configuration is stored in the nvm user row. this configuration should not be changed if the user row is written to assure the correct behavior of the bod12. 7.4.1 power-on reset on vddana por monitors vddana. it is always activated and monitors voltage at startup and also during all the sleep modes. if vddana goes below the threshold voltage, the entire chip is reset. 7.4.2 brown-out detector on vddana bod33 monitors vddana. refer to ?sysctrl ? system controller? on page 128 for details. 7.4.3 brown-out detector on vddcore once the device has started up, bod12 monitors the internal vddcore.
19 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 8. product mapping figure 8-1. sam d20 product mapping this figure represents the full configuration of the atmel ? sam d20 with maximum flash and sram capabilities and a full set of peripherals. refer to the ?configuration summary? on page 3 for details. code sram undefined peripherals reserved undefined global memory space 0x00000000 0x20000000 0x20008000 0x40000000 0x43000000 0x60000000 0x60000200 0xffffffff internal sram sram 0x20000000 0x20008000 ahb-apb bridge a ahb-apb bridge b ahb-apb bridge c peripherals 0x40000000 0x41000000 0x42000000 0x42ffffff reserved pac0 pm sysctrl gclk wdt rtc eic ahb-apb bridge a 0x40000000 0x40000400 0x40000800 0x40000c00 0x40001000 0x40001400 0x40001800 0x40ffffff 0x40001c00 ahb-apb bridge b reserved pac1 dsu nvmctrl port 0x41000000 0x41002000 0x41004000 0x41004400 0x41ffffff 0x41004800 internal flash code 0x00000000 0x00040000 0x1fffffff reserved sercom5 pac2 evsys sercom0 sercom1 sercom2 sercom3 sercom4 ahb-apb bridge c tc7 tc0 tc1 tc2 tc3 tc4 tc5 tc6 adc ac 0x42000000 0x42000400 0x42000800 0x42000c00 0x42001000 0x42001400 0x42001800 0x42002000 0x42001c00 0x42003000 0x42003400 0x42003800 0x42003c00 0x42004000 0x42004400 0x42004800 reserved 0x42ffffff dac 0x42004c00 0x42002400 0x42002800 0x42002c00 ptc 0x42005000 reserved system 0xe0000000 scs reserved reserved rom table reserved system 0xe0000000 0xe000e000 0xe000f000 0xe00ff000 0xe0100000 0xffffffff
20 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 9. memories 9.1 embedded memories z internal high-speed flash z internal high-speed ram, single-cycle access at full speed z dedicated flash area for eeprom emulation 9.2 physical memory map the high-speed bus is implemented as a bus matrix. refer to ?high-speed bus matrix? on page 26 for details. all high- speed bus addresses are fixed, and they are never remapped. the 32-bit physical address space is mapped as follows: table 9-1. sam d20 physical memory map (1) note: 1. x = g, j or e. refer to ?ordering information? on page 4 for details. table 9-2. flash memory parameters (1) notes: 1. x = g, j or e. refer to ?ordering information? on page 4 for details. 2. the number of pages (nvmp) and page size (psz) can be read from the nvm pages and page size bits in the nvm parameter registe r in the nvmctrl (param.nvmp and param.psz, respectively). refer to param for details. memory start address size samd20x18 samd20x17 samd20x16 samd20x15 samd20x14 embedded flash 0x00000000 256kb 128kb 64kb 32kb 16kb embedded sram 0x20000000 32kb 16kb 8kb 4kb 2kb ahb-apb bridge a 0x40000000 64kb 64kb 64kb 64kb 64kb ahb-apb bridge b 0x41000000 64kb 64kb 64kb 64kb 64kb ahb-apb bridge c 0x42000000 64kb 64kb 64kb 64kb 64kb device flash size number of pages (nvmp) page size (psz) row size atsamd20x18 256kb 4096 64 bytes 4 pages = 256 bytes atsamd20x17 128kb 2048 64 bytes 4 pages = 256 bytes atsamd20x16 64kb 1024 64 bytes 4 pages = 256 bytes atsamd20x15 32kb 512 64 bytes 4 pages = 256 bytes atsamd20x14 16kb 256 64 bytes 4 pages = 256 bytes
21 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 9-1. calibration and auxiliary space the values from the automatic calibration row is loaded into their respective registers on startup. 0x00800000 aux0 offset address automatic calibration row calibration and auxiliary space address offset aux0 ? nvm user row aux1 0x00804000 0x00806000 aux1 offset address 0x00806000 area 3 offset address area 1: reserved (64 bits) area 2: device configuration area (64 bits) area 1 address offset area 2 offset address area 3: reserved (128bits) area 4: software calibration area (256bits) 0x00806008 0x00806010 0x00806020 area 4 offset address aux1 0x00806040 0x00000000 nvm base address + nvm size nvm main address space nvm base address calibration and auxiliary space 0x00800000 nvm base address + 0x00800000
22 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 9.3 non-volatile memory (nvm) user row mapping the nvm user row contains calibration data that are automatically read at device power on. the nvm user row can be read at address 0x804000. to write the nvm user row refer to ?nvmctrl ? non-volatile memory controller? on page 258 . note that when writing to the user row the values will only be loaded at device reset. table 9-3. nvm user row mapping notes: 1. on rev c: bit 40 is ?reserved? and default value = 1. 2. on rev c: bit 41 is ?reserved? and default value = 1. bit position name description 2:0 bootprot used to select one of eight different bootloader sizes. refer to ?nvmctrl ? non-volatile memory controller? on page 258 . default value = 7. 3 reserved 6:4 eeprom used to select one of eight different eeprom area sizes. refer to ?nvmctrl ? non-volatile memory controller? on page 258 . default value = 7. 7 reserved 13:8 bod33 level bod33 threshold level (bod33.l evel) at power on. refer to bod33 register. default value = 7. 14 bod33 enable bod33 enable at power on. refer to bod33 register. default value = 1. 16:15 bod33 action bod33 action at power on. refer to bod33 register. default value = 1. 24:17 reserved voltage regulator internal bod(bod12) co nfiguration. these bits are written in production and must not be changed. default value = 0x70. 25 wdt enable wdt enable at power on. refer to wdt ctrl register. default value = 0. 26 wdt always-on wdt always-on at power on. refer to wdt ctrl register. default value = 0. 30:27 wdt period wdt period at power on. refer to wdt config register. default value = 0xb. 34:31 wdt window wdt window mode time-out at power on. refer to wdt config register. default value, window_1 = 0x5. 38:35 wdt ewoffset wdt early warning interrupt time of fset at power on. refer to wdt ewctrl register. default value = 0xb. 39 wdt wen wdt timer window mode enable at power on. refer to wdt ctrl register. default value = 0. 40 (1) bod33 hysteresis bod33 hysteresis configuration at power on. refer to bod33 register. default value = 0. 41 (2) reserved voltage regulator internal bod(bod12) co nfiguration. this bit is written in production and must not be changed. default value = 0. 47:42 reserved 63:48 lock nvm region lock bits. refer to ?nvmctrl ? non-volatile memory controller? on page 258 . default value = 0xffff.
23 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 9.4 nvm software calibration area mapping the nvm software calibration area contains calibration dat a that are measured and written during production test. these calibration values should be read by the application software and written back to the corresponding register. the nvm software calibration area can be read at address 0x806020. the nvm software calibration area can not be written. table 9-4. nvm software calibration area mapping 9.5 serial number each device has a unique 128-bit serial number which is a conc atenation of four 32-bit words contained at the following addresses: word 0: 0x0080a00c word 1: 0x0080a040 word 2: 0x0080a044 word 3: 0x0080a048 the uniqueness of the serial number is guaranteed only when using all 128 bits. bit position name description 2:0 reserved 14:3 reserved 26:15 reserved 34:27 adc linearity adc linearity calibration. should be written to calib register. 37:35 adc biascal adc bias calibration. should be written to calib register. 44:38 osc32k cal osc32kcalibration. should be written to osc32k register. 57:45 reserved 63:58 dfll48m coarse cal dfll48m coarse calibration value. should be written to the dfllval register. 73:64 dfll48m fine cal dfll48m fine calibration value. should be written to the dfllval register. 127:74 reserved
24 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10. processor and architecture 10.1 cortex-m0+ processor the atmel ? sam d20 implements the arm ? cortex ? -m0+ processor, which is based on the armv6 architecture and thumb ? -2 isa. the cortex m0+ is 100% instruction set compatible with its predecessor, the cortex-m0 processor, and upward compatible with the cortex-m3 and cortex-m4 proces sors. the arm cortex-m0+ implemented is revision r0p1. for more information, refer to www.arm.com . 10.1.1 cortex-m0+ configuration note: 1. all software run in privileged mode only the arm cortex-m0+ processor has two bus interfaces: z single 32-bit amba ? 3 ahb-lite? system interface that provides connections to peripherals and all system memory, including flash and ram z single 32-bit i/o port bus interfacing to the port with one-cycle loads and stores 10.1.2 cortex-m0+ peripherals z system control space (scs) z the processor provides debug through registers in the scs. refer to the cortex-m0+ technical reference manual for details ( www.arm.com) . z system timer (systick) z the system timer is a 24-bit timer that extends the functionality of both the processor and the nvic. refer to the cortex-m0+ technical reference manual for details ( www.arm.com) . feature configurable option sam d20 configuration interrupts external interrupts 0-32 32 data endianness little-endian or big-endian little-endian systick timer present or absent present number of watchpoint comparators 0, 1, 2 2 number of breakpoint comparators 0, 1, 2, 3, 4 4 halting debug support present or absent present multiplier fast or small fast (single cycle) single-cycle i/o port present or absent present wake-up interrupt controller supported or not supported not supported vector table offset register present or absent present unprivileged/privileged support present or absent absent memory protection unit not present or 8-region not present reset all registers present or absent absent (1) instruction fetch width 16-bit only or mostly 32-bit 32-bit
25 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z nested vectored interrupt controller (nvic) z external interrupt signals connect to the nvic, and the nv ic prioritizes the interrupts. software can set the priority of each interrupt. the nvic and the cortex-m0+ processor core are closely coupled, providing low latency interrupt processing and efficient processing of late arriving interrupts. refer to ?nested vector interrupt controller? on page 25 and the cortex-m0+ technical reference manual for details ( www.arm.com) . z system control block (scb) z the system control block provides system implementation information, and system control. this includes configuration, control, and reporting of the system exceptions. refer to the cortex-m0+ devices generic user guide for details ( www.arm.com) . 10.1.3 cortex-m0+ address map table 10-1. cortex-m0+ address map 10.1.4 i/o interface 10.1.4.1 overview because accesses to the amba ahb-lite and the single-cycle i/o interface can be made concurrently, the cortex-m0+ processor can fetch the next instructions while accessing the i/os. this enables single-cycle i/o accesses to be sustained for as long as needed. 10.1.4.2 description direct access to port registers. 10.2 nested vector interrupt controller 10.2.1 overview the nested vectored interrupt controller (nvic) in the sam d 20 supports 32 interrupt lines with four different priority levels. for more details, refer to the cortex-m0+ technical reference manual ( www.arm.com) . 10.2.2 interrupt line mapping each of the 32 interrupt lines is connected to one peripheral instance, as shown in the table below. each peripheral can have one or more interrupt flags, located in the peripheral?s interrupt flag status and cl ear (intflag) register. the interrupt flag is set when the interrupt condition occurs. each interrupt in the peripheral can be individually enabled by writing a one to the corresponding bit in the peripheral?s in terrupt enable set (intenset) register, and disabled by writing a one to the corresponding bit in the peripheral?s inte rrupt enable clear (intenclr) register. an interrupt request is generated from the peripheral when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt requests for one peripheral are ored together on system level, generating one interrupt request for each peripheral. an interrupt request will set the corresponding interrupt pending bit in the nvic interrupt pending registers (setpend/clrpend bits in ispr /icpr). for the nvic to activate the interr upt, it must be enabled in the nvic interrupt enable register (setena/clrena bits in iser/icer). the nvic interrupt priority registers ipr0-ipr7 provide a priority field for each interrupt. address peripheral 0xe000e000 system control space (scs) 0xe000e010 system timer (systick) 0xe000e100 nested vectored inte rrupt contro ller (nvic) 0xe000ed00 system control block (scb)
26 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10.3 high-speed bus matrix 10.3.1 features the high-speed bus matrix includes these features: z symmetric crossbar bus switch implementation z allows concurrent accesses from different masters to different slaves z 32-bit data bus z operation at a one-to-one clock frequency with the bus masters peripheral source nvic line eic nmi ? external interrupt controller non maskable interrupt nmi pm ? power manager 0 sysctrl ? system controller 1 wdt ? watchdog timer 2 rtc ? real time counter 3 eic ? external in terrupt controller 4 nvmctrl ? non-volatile memory controller 5 evsys ? event system 6 sercom0 ? serial communication interface 0 7 sercom1 ? serial communication interface 1 8 sercom2 ? serial communication interface 2 9 sercom3 ? serial communication interface 3 10 sercom4 ? serial communication interface 4 11 sercom5 ? serial communication interface 5 12 tc0 ? timer/counter 0 13 tc1 ? timer/counter 1 14 tc2 ? timer/counter 2 15 tc3 ? timer/counter 3 16 tc4 ? timer/counter 4 17 tc5 ? timer/counter 5 18 tc6 ? timer/counter 6 19 tc7 ? timer/counter 7 20 adc ? analog-to-digital converter 21 ac ? analog comparator 22 dac ? digital-to-analog converter 23 ptc ? peripheral touch controller 24
27 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10.3.2 configuration cm0+ 0 dsu 1 high-speed bus slaves internal flash 0 ahb-apb bridge a 1 ahb-apb bridge b 2 ahb-apb bridge c 3 internal sram 4 high-speed bus masters
28 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10.4 ahb-apb bridge the ahb-apb bridge is an ahb slave, providing an inte rface between the high-speed ahb domain and the low-power apb domain. it is used to provide access to the programmable control registers of peripherals (see ?product mapping? on page 19 ). to operate the ahb-apb bridge, the clock (clk_hpbx_ahb) must be enabled. see ?pm ? power manager? on page 101 for details. 10.5 pac ? periphera l access controller 10.5.1 overview there is one pac associated with each ahb-apb bridge. t he pac can provide write protection for registers of each peripheral connected on the same bridge. the pac peripheral bus clock (clk_p acx_apb) is enabled by default, and can be enabled and disabled in the power manager. refer to ?pm ? power manager? on page 101 for details. the pac will continue to operate in any sleep mode where the selected clock source is running. write-protection does not apply for debugger access. when the debugger makes an access to a peripheral, write- protection is ignored so that the debugger can update the register. write-protect registers allow the user to disable a select ed peripheral?s write-protection without doing a read-modify-write operation. these registers are mapped into two i/o memory locations, one for clearing and one for setting the register bits. writing a one to a bit in the write protect clear regist er (wpclr) will clear the corresponding bit in both registers (wpclr and wpset) and disable the write-protection for t he corresponding peripheral, while writing a one to a bit in the write protect set (wpset) regi ster will set the corresponding bit in bo th registers (wpclr and wpset) and enable the write-protection for the corresponding peripheral. both regi sters (wpclr and wpset) will return the same value when read. if a peripheral is write-protected, and if a write access is per formed, data will not be written, and the peripheral will retur n an access error (cpu exception). the pac also offers a safety feature for correct program execution, with a cpu exception generated on double write- protection or double unprotection of a peripheral. if a peripheral n is write-protected and a write to one in wpset[n] is detected, the pac returns an error. this can be used to ensure that the application follows the intended program flow by always following a write-protect with an unprotect, and vice versa. however, in applications where a write-protected peripheral is used in several contexts, e.g., interrupts, ca re should be taken so that either the interrupt can not happen while the main application or other interrupt levels manipul ate the write-protection status, or when the interrupt handler needs to unprotect the peripheral, based on the cu rrent protection status, by reading wpset.
29 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10.6 register description atomic 8-, 16- and 32-bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register, and the 8-bit halves of a 16-bit register can be accessed directly. refer to ?product mapping? on page 19 for pac locations. 10.6.1 write protect clear name: wpclr offset: 0x00 reset: 0x00000000 property: - z bits 31:7 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 6:1 ? eic, rtc, wdt, gclk, sysctrl, pm: write protect disable 0: write-protection is disabled. 1: write-protection is enabled. writing a zero to these bits has no effect. writing a one to these bits will clear the write protect bits for the corresponding peripherals. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 eic rtc wdt gclk sysctrl pm access r r/w r/w r/w r/w r/w r/w r reset00000000
30 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10.6.2 write protect set name: wpset offset: 0x04 reset: 0x00000000 property: - z bits 31:7 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 6:1 ? eic, rtc, wdt, gclk, sysctrl, pm: write protect enable 0: write-protection is disabled. 1: write-protection is enabled. writing a zero to these bits has no effect. writing a one to these bits will set the write protect bit for the corresponding peripherals. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 15 14 13 12 11 10 9 8 accessrrrrrrrr reset00000000 bit76543210 eic rtc wdt gclk sysctrl pm access r r/w r/w r/w r/w r/w r/w r reset00000000
31 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10.6.3 pac1 register description write protect clear name: wpclr offset: 0x00 reset: 0x00000002 property: - z bits 31:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:1 ? port, nvmctrl, dsu: write protect 0: write-protection is disabled. 1: write-protection is enabled. writing a zero to these bits has no effect. writing a one to these bits will clear the write protect bit for the corresponding peripherals. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 port nvmctrl dsu access r r r r r/w r/w r/w r reset00000010
32 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 write protect set name: wpset offset: 0x04 reset: 0x00000002 property: - z bits 31:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:1 ? port, nvmctrl, dsu: write protect 0: write-protection is disabled. 1: write-protection is enabled. writing a zero to these bits has no effect. writing a one to these bits will set the write protect bit for the corresponding peripherals. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 15 14 13 12 11 10 9 8 accessrrrrrrrr reset00000000 bit76543210 port nvmctrl dsu accessrrrrr/wr/wr/wr reset00000010
33 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10.6.4 pac2 register description write protect clear name: wpclr offset: 0x00 reset: 0x00100000 property: - z bits 31:20 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to reset value when this register is written. t hese bits will always return reset value when read. z bits 19:1 ? ptc, dac, ac, adc, tc7, tc6, tc5, tc4, tc3, tc2, tc1, tc0, sercom5, sercom4, sercom3, sercom2, sercom1, sercom0, evsys: write protect 0: write-protection is disabled. 1: write-protection is enabled. writing a zero to these bits has no effect. writing a one to these bits will clear the write protect bit for the corresponding peripherals. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 ptc dac ac adc access r r r r r/w r/w r/w r/w reset00010000 bit151413121110 9 8 tc7tc6tc5tc4tc3tc2tc1tc0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 sercom5 sercom4 sercom3 sercom2 sercom1 sercom0 evsys access r/w r/w r/w r/w r/w r/w r/w r reset00000000
34 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 write protect set name: wpset offset: 0x04 reset: 0x00100000 property: - z bits 31:20 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to reset value when this register is written. t hese bits will always return reset value when read. z bits 19:1 ? ptc, dac, ac, adc, tc7, tc6, tc5, tc4, tc3, tc2, tc1, tc0, sercom5, sercom4, sercom3, sercom2, sercom1, sercom 0, evsys: write protect enable 0: write-protection is disabled. 1: write-protection is enabled. writing a zero to these bits has no effect. writing a one to these bits will set the write protect bit for the corresponding peripherals. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 ptc dac ac adc access r r r r r/w r/w r/w r/w reset00010000 bit151413121110 9 8 tc7tc6tc5tc4tc3tc2tc1tc0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 sercom5 sercom4 sercom3 sercom2 sercom1 sercom0 evsys access r/w r/w r/w r/w r/w r/w r/w r reset00000000
35 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 11. peripherals configuration overview the following table shows an overview of all the peripherals in the device. the irq line column shows the interrupt mapping, as described in ?nested vector interrupt controller? on page 25 . the ahb and apb clock indexes correspond to the bit in the ahbmask and apbmask (x = a, b or c) registers in the power manager, while the enabled at reset column shows whet her the peripheral clock is enabled at reset (y) or not (n). refer to the power manager ahbmask , apbamask , apbbmask and apbcmask registers for details. the generic clock index column corresponds to the value of the generic clock selection id bits in the generic clock control register (clkctrl.id) in the gener ic clock controller. refer to the gclk clkctrl register description for details. the pac index column corresponds to the bit in the paci (i = 0, 1 or 2) registers, while the prot at reset column shows whether the peripheral is protected at reset (y) or not (n). refer to ?pac ? peripheral access controller? on page 28 for details. the numbers in the events user column correspond to the value of the user multiplexer selection bits in the user multiplexer register (user.user) in the event system. see the user register description and table 22-6 for details. the numbers in the events generator column correspond to the value of the event generator bits in the channel register (channel.evgen) in the event system. see the channel register description and table 22-3 for details. table 11-1. peripherals configuration overview peripheral name base address irq line ahb clock apb clock generic clock pac events index enabled at reset index enabled at reset index index prot at reset user generator ahb-apb bridge a 0x40000000 0 y pac0 0x40000000 0 y pm 0x40000400 0 1 y 1 n sysctrl 0x40000800 1 2 y 0: dfll48m reference 2 n gclk 0x40000c00 3 y 3 n wdt 0x40001000 2 4 y 1 4 n rtc 0x40001400 3 5 y 2 5 n 1: cmp0/alarm0 2: cmp1 3: ovf 4-11: per0-7 eic 0x40001800 nmi, 4 6 y 3 6 n 12-27: extint0-15 ahb-apb bridge b 0x41000000 1 y pac1 0x41000000 0 y dsu 0x41002000 3 y 1 y 1 y nvmctrl 0x41004000 5 4 y 2 y 2 n port 0x41004400 3 y 3 n ahb-apb bridge c 0x42000000 2 y pac2 0x42000000 0 n evsys 0x42000400 6 1 n 4-11: one per channel 1 n sercom0 0x42000800 7 2 n 13: core 12: slow 2 n sercom1 0x42000c00 8 3 n 14: core 12: slow 3 n sercom2 0x42001000 9 4 n 15: core 12: slow 4 n sercom3 0x42001400 10 5 n 16: core 12: slow 5 n
36 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 sercom4 0x42001800 11 6 n 17: core 12: slow 6 n sercom5 0x42001c00 12 7 n 18: core 12: slow 7 n tc0 0x42002000 13 8 n 19 8 n 0: tc 28: ovf 29-30: mc0-1 tc1 0x42002400 14 9 n 19 9 n 1: tc 31: ovf 32-33: mc0-1 tc2 0x42002800 15 10 n 20 10 n 2: tc 34: ovf 35-36: mc0-1 tc3 0x42002c00 16 11 n 20 11 n 3: tc 37: ovf 38-39: mc0-1 tc4 0x42003000 17 12 n 21 12 n 4: tc 40: ovf 41-42: mc0-1 tc5 0x42003400 18 13 n 21 13 n 5: tc 43: ovf 44-45: mc0-1 tc6 0x42003800 19 14 n 22 14 n 6: tc 46: ovf 47-48: mc0-1 tc7 0x42003c00 20 15 n 22 15 n 7: tc 49: ovf 50-51: mc0-1 adc 0x42004000 21 16 y 23 16 n 8: start 9: sync 52: resrdy 53: winmon ac 0x42004400 22 17 n 24: dig 25: ana 17 n 10-11: comp0-1 54-55: comp0-1 56: win0 dac 0x42004800 23 18 n 26 18 n 12: start 57: empty ptc 0x42004c00 24 19 n 27 19 n 13: stconv 58: eoc 59: wcomp table 11-1. peripherals configuration overview peripheral name base address irq line ahb clock apb clock generic clock pac events index enabled at reset index enabled at reset index index prot at reset user generator
37 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12. dsu ? device service unit 12.1 overview the device service unit (dsu) provides a means to detect debugger probes. this enables the arm debug access port (dap) to have control over multiplexed debug pads and cpu reset. the dsu also provides system-level services to debug adapters in an arm debug system. it implements a coresight debug rom that provides device identification as well as identification of other debug components in the system. hence, it complies with the arm peripheral identification specification. the dsu also provides system services to applications that need memory testing, as required for iec60730 class b compliance, for example. the dsu can be accessed simultaneously by a debugger and the cpu, as it is connected on the high-speed bus matrix. for security reasons, some of the dsu features will be limited or unavailable when the device is protected by the nvmctrl security bit (refer to ?security bit? on page 264 ). 12.2 features z cpu reset extension z debugger probe detection (cold- and hot-plugging) z chip-erase command and status z 32-bit cyclic redundancy check (crc32) of any memory accessible through the bus matrix z arm ? coresight? compliant device identification z two debug communications channels z debug access port security filter z onboard memory built-in self-test (mbist) 12.3 block diagram figure 12-1. dsu bock diagram d su s w c lk co re s i g ht r om dap s e cu rity filter c rc-32 mbi st c hip eras e r e s et c pu_reset_extens i o n cp u d ap s wdi o nvm c trl db g m high-speed high- spee bus matrix matr us m m s d e b ugger_presen t d e b u g g e r p r o b e interfa c e a hb-a p portmux
38 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. 12.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 12.5.1 i/o lines the swclk pin is by default assigned to the dsu module to allow debugger probe detection and the condition to stretch the cpu reset phase. for more information, refer to ?debugger probe detection? on page 39 . the hot-plugging feature depends on the port configuration. if the swclk pin function is changed in the port or if the port_mux is disabled, the hot-plugging feature is disabled until a power-reset or an external reset. 12.5.2 power management the dsu will continue to operate in any sleep mode where the selected source clock is running. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 12.5.3 clocks the dsu bus clocks (clk_dsu_apb and clk_dsu_ahb) can be enabled and disabled in the power manager. for more information on the clk_dsu_apb and clk_dsu_ahb clock masks, refer to ?pm ? power manager? on page 101 . 12.5.4 interrupts not applicable. 12.5.5 events not applicable. 12.5.6 register access protection all registers with write access are optionally write-protec ted by the peripheral access controller (pac), except the following registers: z debug communication channel 0 register (dcc0) z debug communication channel 1 register (dcc1) write-protection is denoted by the write-protection property in the register description. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 12.5.7 analog connections not applicable. signal name type description reset digital input external reset swclk digital input sw clock swdio digital i/o sw bidirectional data pin
39 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.6 debug operation 12.6.1 principle of operation the dsu provides basic services to allow on-chip debug using the arm debug access port and the arm processor debug resources: z cpu reset extension z debugger probe detection for more details on the arm debug components, refer to the arm debug interface v5architecture specification. 12.6.2 cpu rese t extension ?cpu reset extension? refers to the extension of the reset phase of the cpu core after the external reset is released. this ensures that the cpu is not executing code at startup while a debugger connects to the system. it is detected on a reset release event when swclk is low. at startup, swclk is internally pulled up to avoid false detection of a debugger if swclk is left unconnected. when the cpu is held in the reset extension phase, the cpu reset extension bit (crstext) of the status a regi ster (statusa.crstext) is set. to release the cpu, write a one to statusa.crstext. statusa. crstext will then be set to zero. writing a zero to statusa.crstext has no effect. for security reasons, it is not possible to release the cpu reset extension when the device is protected by the nvmctrl security bit (refer to ?security bit? on page 264 ). trying to do so sets the protection error bit (perr) of the status a register (statusa.perr). figure 12-2. typical cpu reset extension set and clear timing diagram 12.6.3 debugger probe detection 12.6.3.1 cold-plugging cold-plugging is the detection of a debugger when the system is in reset. cold-plugging is detected when the cpu reset extension is requested, as described above. 12.6.3.2 hot-plugging hot-plugging is the detection of a debugger probe when the system is not in reset. hot-plugging is not possible under reset because the detector is reset when por or reset are asserted. hot-plugging is active when a swclk falling edge is detected. the swclk pad is multiplexed with other func tions and the user must ensure that its default function is assigned to the debug system. if the swclk function is c hanged, the hot-plugging feature is disabled until a power- reset or external reset occurs. availability of the hot-pl ugging feature can be read from the hot-plugging enable bit of the status b register (statusb.hpe). dsu crstext clear swclk cpu reset extension cpu_state reset running re s e t
40 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 12-3. hot-plugging detection timing diagram the presence of a debugger probe is detected when either hot- plugging or cold-plugging is detected. once detected, the debugger present bit of the status b register (statusb.d bgpres) is set. for security reasons, hot-plugging is not available when the device is protected by the nvmctrl security bit (refer to ?security bit? on page 264 ). this detection requires that pads are correctly powered. thus, at cold startup, this detection cannot be done until por is released. if the device is protected, cold-plugging is the only way to detect a debugger probe, and so the external reset timing must be longer than the por timing. if external reset is deasserted before por release, the user must retry the procedure above until it gets connected to the device. 12.7 chip-erase chip-erase consists of removing all sensitive information stor ed in the chip and clearing the nvmctrl security bit (refer to ?security bit? on page 264 ). hence, all volatile memories and the flash array (including the eeprom emulation area) will be erased. the flash auxiliary rows, including the user row, will not be erased. when the device is protected, the debugger must reset the device in order to be detected. this ens ures that internal registers are reset after the protected state is removed. the chip-erase operation is triggered by writing a one to the chip-erase bit in the control register (ctrl.ce). this command will be discarded if the dsu is pr otected by the peripheral access controller (pac). once issued, the module clears volatile memories prior to erasing the flash array. to ensure that the chip-erase operation is completed, check the done bit of the status a register (statusa.done). the chip-erase operation depends on clocks and power management features that can be altered by the cpu. for that reason, it is recommended to issue a chip- erase after a cold-plugging procedure to ensure that the device is in a known and safe state. the recommended sequence is as follows: 1. issue the cold-plugging procedure (refer to ?cold-plugging? on page 39 ). the device then: 1. detects the debugger probe 2. holds the cpu in reset 2. issue the chip-erase command by writing a one to ctrl.ce. the device then: 1. clears the system volatile memories 2. erases the whole flash array (including the ee prom emulation area, not including auxiliary rows) 3. erases the lock row, removing the nvmctrl security bit protection 3. check for completion by polling statusa.done (read as one when completed). 4. reset the device to let the nvmctrl update fuses. 12.8 programming programming of the flash or ram memories is available when the device is not protected by the nvmctrl security bit (refer to ?security bit? on page 264 ). 1. at power up, reset is driven low by a debugger. the on-chip regulator holds the system in a por state until the input supply is above the por threshold (refer to ?power-on reset (por) characteristics? on page 573 ). the sys- swclk hot-plugging cpu_state reset running r eset
41 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 tem continues to be held in this static state until the internally regulated supplies have reached a safe operating state. 2. the pm starts, clocks are switched to the slow clock (core clock, system clock, flash clock and any bus clocks that do not have clock gate control). internal resets are maintained due to the external reset. 3. the debugger maintains a low level on swclk. releasing reset results in a debugger cold-plugging procedure. 4. the debugger generates a clock signal on the swclk pin, the debug access port (dap) receives a clock. 5. the cpu remains in reset due to the cold-plugging procedure; meanwhile, the rest of the system is released. 6. a chip-erase is issued to ensure that the flash is fully erased prior to programming. 7. programming is available through the ahb-ap. 8. after operation is completed, the chip can be restarted either by asserting reset , toggling power or writing a one to the status a register cpu reset phase extension bit (statusa.crstext). make sure that the swclk pin is high when releasing reset to prevent extending the cpu reset. 12.9 intellectual pr operty protection intellectual property protection consists of restricting access to internal memories from external tools when the device is protected, and is accomplished by setti ng the nvmctrl security bit (refer to ?security bit? on page 264 ). this protected state can be removed by issuing a chip-erase (refer to ?chip-erase? on page 40 ). when the device is protected, read/write accesses using the ahb-ap are limited to the dsu address range and dsu commands are restricted. the dsu implements a security filter that monitors the ahb transactions generated by the arm ahb-ap inside the dap. if the device is protected, then ahb-ap read/write accesses outside the dsu external address range are discarded, causing an error response that sets the arm ahb-ap sticky erro r bits (refer to the arm debug interface v5 architecture specification on http://www.arm.com ). the dsu is intended to be accessed either: z internally from the cpu, without any limitation, even when the device is protected z externally from a debug adapter, with some restrictions when the device is protected for security reasons, dsu features have limitations when us ed from a debug adapter. to differentiate external accesses from internal ones, the first 0x100 bytes of the dsu register map have been replicated at offset 0x100: z the first 0x100 bytes form the internal address range z the next 0x100 bytes form the external address range when the device is protected, the dap can only issue mem-ap accesses in the dsu address range limited to the 0x100- 0x2000 offset range. the dsu operating registers are located in the 0x00-0xff area and remapped in 0x100-0x1ff to differentiate accesses coming from a debugger and the cpu. if the device is protected and an access is issued in the region 0x100-0x1ff, it is subject to security restrictions. for more information, refer to table 12-1 .
42 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 some features not activated by apb transactions are not available when the device is protected: 12.10 device identification device identification relies on the arm coresight component identification scheme, which allows the chip to be identified as an atmel device implementing a dsu. the dsu contains identification registers to differentiate the device. 12.10.1 coresight identification a system-level arm coresight rom table is present in the device to identify the vendor and the chip identification method. its address is provided in the mem-ap base regist er inside the arm debug access port. the coresight rom implements a 64-bit conceptual id composed as follows from the pid0 to pid7 coresight rom table registers: figure 12-5. conceptual 64-bit peripheral id figure 12-4. apb memory mapping 0x0000 dsu operating registers internal address range (cannot be accessed from debug tools when the device is protected by the nvmctrl security bit) 0x00fc 0x0100 replicated dsu operating registers external address range (can be accessed from debug tools with some restrictions) 0x01fd empty 0x1000 dsu coresight rom 0x1ffc table 12-1. feature availability under protection features availability when the device is protected cpu reset extension yes debugger cold-plugging yes debugger hot-plugging no
43 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 for more information, refer to the arm debug interface version 5 architecture specification. 12.10.2 dsu chip identification method: the dsu did register identifies the device by implementing the following information: z processor identification z product family identification z product series identification z device select 12.11 functional description 12.11.1 principle of operation the dsu provides memory services such as crc32 or mbis t that require almost the same interface. hence, the address, length and data registers are shared. they must be configured first; then a command can be issued by writing the control register. when a command is ongoing, other commands are discarded until the current operation is completed. hence, the user must wait for the statusa.done bit to be set prior to issuing another one. 12.11.2 basic operation 12.11.2.1 initialization the module is enabled by enabling its clocks. for more details, refer to ?clocks? on page 38 . the dsu registers can be write-protected. refer to ?pac ? peripheral access controller? on page 28 . 12.11.2.2 operation fr om a debug adapter debug adapters should access the dsu registers in the external address range 0x100 ? 0x2000. if the device is protected by the nvmctrl security bit (refer to ?security bit? on page 264 ), accessing the first 0x100 bytes causes the system to return an error (refer to ?intellectual property protection? on page 41 ). 12.11.2.3 operation from the cpu there are no restrictions when accessing dsu registers from the cpu. however, the user should access dsu registers in the internal address range (0x0 ? 0x100) to avoid external security restrictions (refer to ?intellectual property protection? on page 41 ). table 12-2. conceptual 64-bit pe ripheral id bit descriptions field size description location jep-106 cc code 4 atmel continuation code: 0x0 pid4 jep-106 id code 7 atmel device id: 0x1f pid1+pid2 4kb count 4 indicates that the coresight component is a rom: 0x0 pid4 revand 4 not used; read as 0 pid3 cusmod 4 not used; read as 0 pid3 partnum 12 contains 0xcd0 to indicate that dsu is present pid0+pid1 revision 4 dsu revision (starts at 0x0 and increments by 1 at both major and minor revisions). identifies dsu identifica tion method variants. if 0x0, this indicates that device i dentification can be completed by reading the device identificatio n register (did) pid3
44 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.11.3 32-bit cyclic redundancy check (crc32) the dsu unit provides support for calculating a cyclic redundancy check (crc32) value for a memory area (including flash and ahb ram). when the crc32 command is issued from: z the internal range, the crc32 can be operated at any memory location z the external range, the crc32 operation is restricted; data, addr and length values are forced (see below) the algorithm employed is the industry standard crc 32 algorithm using the generator polynomial 0xedb88320 (reversed representation). 12.11.3.1 starting crc32 calculation crc32 calculation for a memory range is started after writi ng the start address into the address register (addr) and the size of the memory range into the length register (length). both must be word-aligned. the initial value used for the crc32 calculation must be written to the data register. this value will usually be 0xffffffff, but can be, for example, the result of a pr evious crc32 calculation if generating a common crc32 of separate memory blocks. once completed, the calculated crc32 value can be read out of the data register. the read value must be complemented to match standard crc32 implementations or kept non-inverted if used as starting point for subsequent crc32 calculations. if the device is in protected state by the nvmctrl security bit (refer to ?security bit? on page 264 ), it is only possible to calculate the crc32 of the whole flash array when operated from the external address space. in most cases, this area will be the entire onboard non-volatile memory. the address, length and data registers will be forced to predefined values once the crc32 operation is started, and values written by the user are ignored. this allows the user to verify the contents of a protected device. the actual test is started by writing a one in the 32-bit c yclic redundancy check bit of the control register (ctrl.crc). a running crc32 operation can be canceled by resetting the module (writing a one to ctrl.swrst). 12.11.3.2 interpreting the results the user should monitor the status a register. when the oper ation is completed, statusa.done is set. then the bus error bit of the status a register (statusa.berr) must be read to ensure that no bus error occurred. 12.11.4 debug communication channels the debug communication channels (dcco and dcc1) consist of a pair of registers with associated handshake logic, accessible by both cpu and debugger even if the device is protected by the nvmctrl security bit (refer to ?security bit? on page 264 ). the registers can be used to exchange data between the cpu and the debugger, during run time as well as in debug mode. this enables the user to build a custom debug protocol using only these registers. the dcc0 and dcc1 registers are accessible when the protected state is active. when the device is protected, however, it is not possible to connect a debugger while the cpu is running (statusa.c rstext is not writable and the cpu is held under reset). dirty bits in the status registers indicate whether a new value has been written in dcc0 or dcc1. these bits,dcc0d and dcc1d, are located in the statusb regist ers. they are automatically set on write and cleared on table 12-3. amod bit descriptions when operating crc32 amod[1:0] short name external range restrictions 0 array crc32 is restricted to the full flash array area (eeprom emulation area not included) data forced to 0xffffffff before calculation (no seed) 1 eeprom crc32 of the whole eeprom emulation area data forced to 0xffffffff before calculation (no seed) 2-3 reserved
45 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 read. the dcc0 and dcc1 registers are shared with the onboar d memory testing logic (mbist). accordingly, dcc0 and dcc1 must not be used while performing mbist operations. 12.11.5 testing of onboard memories (mbist) the dsu implements a feature for automatic testing of memo ry also known as mbist. this is primarily intended for production test of onboard memories. mbist cannot be operated from the external address range when the device is protected by the nvmctrl security bit (refer to ?security bit? on page 264 ). if a mbist command is issued when the device is protected, a protection error is reported in the prot ection error bit in the status a register (statusa.perr). 1. algorithm the algorithm used for testing is a type of march algorithm called "march lr". this algorithm is able to detect a wide range of memory defects, while still keeping a linear run time. the algorithm is: 1. write entire memory to 0, in any order. 2. bit for bit read 0, write 1, in descending order. 3. bit for bit read 1, write 0, read 0, write 1, in ascending order. 4. bit for bit read 1, write 0, in ascending order. 5. bit for bit read 0, write 1, read 1, write 0, in ascending order. 6. read 0 from entire memory, in ascending order. the specific implementation used has a run time of o(14n) where n is the number of bits in the ram. the detected faults are: z address decoder faults z stuck-at faults z transition faults z coupling faults z linked coupling faults z stuck-open faults 2. starting mbist to test a memory, you need to write the start address of the memory to the addr.addr bit group, and the size of the memory into the length register. see ?physical memory map? on page 20 to know which memories are avail- able, and which address they are at. for best test coverage, an entire physical memory block should be tested at once. it is possible to test only a sub- set of a memory, but the test coverage will then be somewhat lower. the actual test is started by writing a one to ctrl.m bist. a running mbist operation can be canceled by writing a one to ctrl.swrst. 3. interpreting the results the tester should monitor the statusa register. when the operation is completed, statusa.done is set. there are three different modes: z addr.amod=0: exit-on-error (default) in this mode, the algorithm terminates either when a fault is detected or on successful completion. in both cases, statusa.done is set. if an error was detected, statusa.fail will be set. user then can read the data and addr registers to locate the fault. refer to ?locating errors? on page 45 . z addr.amod=1: pause-on-error in this mode, the mbist algorithm is paused when an error is detected. in such a situation, only statusa.fail is asserted. the state machine waits for user to clear stat usa.fail by writing a one in statusa.fail to resume. prior to resuming, user can read the data and addr registers to locate the fault. refer to ?locating errors? on page 45 . 4. locating errors if the test stops with statusa.fail set, one or more bits failed the test. the test stops at the first detected error. the position of the failing bit can be found by reading the following registers:
46 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z addr: address of the word containing the failing bit. z data: contains data to identify which bit failed, and during which phase of the test it failed. the data register will in this case contains the following bit groups: table 12-4. data bits description when mbist operation returns an error z bit_index: contains the bit number of the failing bit z phase: indicates which phase of the test failed and the cause of the error. see table 12-5 on page 46 . 12.11.6 system services availability when accessed externally external access: access performed in t he dsu address offset 0x200-0x1fff range. internal access: access performed in the dsu address offset 0x0-0x100 range. bit3130292827262524 bit2322212019181716 bit151413121110 9 8 phase bit76543210 bit_index table 12-5. mbist operation phases phase test actions 0 write all bits to zero. this phase cannot fail. 1 read 0, write 1, increment address 2 read 1, write 0 3 read 0, write 1, decrement address 4 read 1, write 0, decrement address 5 read 0, write 1 6 read 1, write 0, decrement address 7 read all zeros. bit_index is not used
47 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 12-6. available features when operated from the external address range features availability from the external address range chip-erase command and status yes crc32 yes, only full array or full eeprom coresight compliant de vice identification yes debug communication channels yes testing of onboard memories (mbist) yes statusa.crstext clearing no (statusa.perr is set when attempting to do so)
48 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.12 register summary table 12-7. register summary offset name bit pos 0x0000 ctrl 7:0 ce mbist crc swrst 0x0001 statusa 7:0 perr fail berr crstext done 0x0002 statusb 7:0 hpe dccd1 dccd0 dbgpres prot 0x0003 reserved 0x0004 addr 7:0 addr[5:0] 0x0005 15:8 addr[13:6] 0x0006 23:16 addr[21:14] 0x0007 31:24 addr[29:22] 0x0008 length 7:0 length[5:0] 0x0009 15:8 length[13:6] 0x000a 23:16 length[21:14] 0x000b 31:24 length[29:22] 0x000c data 7:0 data[7:0] 0x000d 15:8 data[15:8] 0x000e 23:16 data[23:16] 0x000f 31:24 data[31:24] 0x0010 dcc0 7:0 data[7:0] 0x0011 15:8 data[15:8] 0x0012 23:16 data[23:16] 0x0013 31:24 data[31:24] 0x0014 dcc1 7:0 data[7:0] 0x0015 15:8 data[15:8] 0x0016 23:16 data[23:16] 0x0017 31:24 data[31:24] 0x0018 did 7:0 devsel[7:0] 0x0019 15:8 die[3:0] revision[3:0] 0x001a 23:16 family[0] series[5:0] 0x001c 31:24 processor[3:0] family[4:1] 0x001d reserved ... ... 0x00ff reserved 0x0100- 0x01ff external address range: replicates the 0x00:0x1c address range, gives access to the same resources but with security restrictions when the device is protected. this address range is the only one accessible externally (using the arm dap) when the device is protected.
49 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x1000 entry0 7:0 fmt epres 0x1001 15:8 addoff[3:0] 0x1002 23:16 addoff[11:4] 0x1003 31:24 addoff[19:12] 0x1004 entry1 7:0 fmt epres 0x1005 15:8 addoff[3:0] 0x1006 23:16 addoff[11:4] 0x1007 31:24 addoff[19:12] 0x1008 end 7:0 end[7:0] 0x1009 15:8 end[15:8] 0x100a 23:16 end[23:16] 0x100b 31:24 end[31:24] 0x1fcc memtype 7:0 smemp 0x1fcd 15:8 0x1fce 23:16 0x1fcf 31:24 0x1fd0 pid4 7:0 fkbc[3:0] jepcc[3:0] 0x1fd1 15:8 0x1fd2 23:16 0x1fd3 31:24 0x1fd4 reserved ? ? 0x1fdf reserved 0x1fe0 pid0 7:0 partnbl[7:0] 0x1fe1 15:8 0x1fe2 23:16 0x1fe3 31:24 0x1fe4 pid1 7:0 jepidcl[3:0] partnbh[3:0] 0x1fe5 15:8 0x1fe6 23:16 0x1fe7 31:24 0x1fe8 pid2 7:0 revision[3:0] jepu jepidch[2:0] 0x1fe9 15:8 0x1fea 23:16 0x1feb 31:24 0x1fec pid3 7:0 revand[3:0] cusmod[3:0] 0x1fed 15:8 0x1fee 23:16 0x1fef 31:24
50 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x1ff0 cid0 7:0 preambleb0[7:0] 0x1ff1 15:8 0x1ff2 23:16 0x1ff3 31:24 0x1ff4 cid1 7:0 cclass[3:0] preamble[3:0] 0x1ff5 15:8 0x1ff6 23:16 0x1ff7 31:24 0x1ff8 cid2 7:0 preambleb2[7:0] 0x1ff9 15:8 0x1ffa 23:16 0x1ffb 31:24 0x1ffc cid3 7:0 preambleb3[7:0] 0x1ffd 15:8 0x1ffe 23:16 0x1fff 31:24
51 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 38 for details.
52 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.1 control name: ctrl offset: 0x0000 reset: 0x00 property: write-protected z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? ce: chip erase writing a zero to this bit has no effect. writing a one to this bit starts the chip-erase operation. z bit 3 ? mbist: memory built-in self-test writing a zero to this bit has no effect. writing a one to this bit starts the memory bist algorithm. z bit 2 ? crc: 32-bit cyclic redundancy check writing a zero to this bit has no effect. writing a one to this bit starts the cyclic redundancy check algorithm. z bit 1 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. z bit 0 ? swrst: software reset writing a zero to this bit has no effect. writing a one to this bit resets the module. bit 76543210 ce mbist crc swrst access r r r w w w r w reset00000000
53 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.2 status a name: statusa offset: 0x0001 reset: 0x00 property: write-protected z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? perr: protection error writing a zero to this bit has no effect. writing a one to this bit clears the protection error bit. this bit is set when a command that is not allowed in protected state is issued. z bit 3 ? fail: failure writing a zero to this bit has no effect. writing a one to this bit clears the failure bit. this bit is set when a dsu operation failure is detected. z bit 2 ? berr: bus error writing a zero to this bit has no effect. writing a one to this bit clears the bus error bit. this bit is set when a bus error is detected. z bit 1 ? crstext: cpu reset phase extension writing a zero to this bit has no effect. writing a one to this bit clears the cpu reset phase extension bit. this bit is set when a debug adapter cold-plugging is detected, which extends the cpu reset phase. z bit 0 ? done: done writing a zero to this bit has no effect. writing a one to this bit clears the done bit. this bit is set when a dsu operation is completed. bit 76543210 perr fail berr crstext done access r r r r/w r/w r/w r/w r/w reset00000000
54 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.3 status b name: statusb offset: 0x0002 reset: 0x1x property: write-protected z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? hpe: hot-plugging enable writing a zero to this bit has no effect. writing a one to this bit has no effect. this bit is set when hot-plugging is enabled. this bit is cleared when hot-plugging is disabled. this is the case when the swclk function is changed. only a power-reset or a external reset can set it again. z bits 3:2 ? dccdx [x=1..0]: debu g communication channel x dirty writing a zero to this bit has no effect. writing a one to this bit has no effect. this bit is set when dccx is written. this bit is cleared when dccx is read. z bit 1 ? dbgpres: debugger present writing a zero to this bit has no effect. writing a one to this bit has no effect. this bit is set when a debugger probe is detected. this bit is never cleared. z bit 0 ? prot: protected writing a zero to this bit has no effect. writing a one to this bit has no effect. this bit is set at powerup when the device is protected. this bit is never cleared. bit 76543210 hpe dccd1 dccd0 dbgpres prot accessrrrrrrrr reset000100xx
55 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.4 address name: addr offset: 0x0004 reset: 0x00000000 property: write-protected z bits 31:2 ? addr[29:0]: address initial word start address needed for memory operations. z bits 1:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit 3130292827262524 addr[29:22] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 addr[21:14] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 addr[13:6] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 addr[5:0] access r/w r/w r/w r/w r/w r/w r r reset00000000
56 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.5 length name: length offset: 0x0008 reset: 0x00000000 property: write-protected z bits 31:2 ? length[29:0]: length length in words needed for memory operations. z bits 1:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit 3130292827262524 length[29:22] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 length[21:14] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 length[13:6] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 length[5:0] access r/w r/w r/w r/w r/w r/w r r reset00000000
57 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.6 data name: data offset: 0x000c reset: 0x00000000 property: write-protected z bits 31:0 ? data[31:0]: data memory operation initial value or result value. bit 3130292827262524 data[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 data[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 data[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 data[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
58 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.7 debug communication channel n name: dccn offset: 0x0010+n*0x4 [n=0..1] reset: 0x00000000 property: - z bits 31:0 ? data[31:0]: data data register. bit 3130292827262524 data[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 data[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 data[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 data[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
59 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.8 device identification name: did offset: 0x0018 reset: 0x1000xxxx property: write-protected the information in this register is related to the ordering code. refer to the ?ordering information? on page 4 for details. z bits 31:28 ? processor[3:0]: processor the value of this field defines the processor used on the device. for this device, the value of this field is 0x1, cor- responding to the arm cortex-m0+ processor. z bits 27:23 ? family[4:0]: product family the value of this field corresponds to the product family part of the ordering code. for this device, the value of this field is 0x0, corresponding to the sam d family of base line microcontrollers. z bits 21:16 ? series[5:0]: product series the value of this field corresponds to the product series par t of the ordering code. for this device, the value of this field is 0x00, corresponding to a product with the cortex-m0+ processor and a basic feature set. z bits 15:12 ? die[3:0]: die identification identifies the die in the family. z bits 11:8 ? revision[3:0]: revision identifies the die revision number. bit 3130292827262524 processor[3:0] family[4:1] accessrrrrrrrr reset00000000 bit 2322212019181716 family[0] series[5:0] accessrrrrrrrr reset00000000 bit 151413121110 9 8 die[3:0] revision[3:0] accessrrrrrrrr resetxxxxxxxx bit 76543210 devsel[7:0] accessrrrrrrrr resetxxxxxxxx
60 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 7:0 ? devsel[7:0]: device selection devsel is used to identify a device within a product family and product series. the value corresponds to the flash memory density, pin count and device variant parts of the ordering code. refer to table 12-8 . for details. table 12-8. device selection devsel device flash ram pincount 0x0 samd20j18a 256kb 32kb 64 0x1 samd20j17a 128kb 16kb 64 0x2 samd20j16a 64kb 8kb 64 0x3 samd20j15a 32kb 4kb 64 0x4 samd20j14a 16kb 2kb 64 0x5 samd20g18a 256kb 32kb 48 0x6 samd20g17a 128kb 16kb 48 0x7 samd20g16a 64kb 8kb 48 0x8 samd20g15a 32kb 4kb 48 0x9 samd20g14a 16kb 2kb 48 0xa samd20e18a 256kb 32kb 32 0xb samd20e17a 128kb 16kb 32 0xc samd20e16a 64kb 8kb 32 0xd samd20e15a 32kb 4kb 32 0xe samd20e14a 16kb 2kb 32 0xf-0xff reserved
61 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.9 coresight rom table entry n name: entryn offset: 0x1000+n*0x4 [n=0..1] reset: 0xxxxxx00x property: write-protected z bits 31:12 ? addoff[19:0]: address offset the base address of the component, relative to the base address of this rom table. z bits 11:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? fmt: format always read as one, indicates a 32-bit rom table. z bit 0 ? epres: entry present this bit indicates whether an entry is present at this location in the rom table. this bit is set at powerup if the device is not pr otected indicating that the entry is not present. this bit is cleared at powerup if the device is not protected indicating that the entry is present. bit 3130292827262524 addoff[19:12] accessrrrrrrrr resetxxxxxxxx bit 2322212019181716 addoff[11:4] accessrrrrrrrr resetxxxxxxxx bit 151413121110 9 8 addoff[3:0] accessrrrrrrrr resetxxxx0000 bit 76543210 fmt epres accessrrrrrrrr reset0000001x
62 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.10 coresight rom table end name: end offset: 0x1008 reset: 0x00000000 property: - z bits 31:0 ? end[31:0]: end marker indicates the end of the coresight rom table entries. bit 3130292827262524 end[31:24] accessrrrrrrrr reset00000000 bit 2322212019181716 end[23:16] accessrrrrrrrr reset00000000 bit 151413121110 9 8 end[15:8] accessrrrrrrrr reset00000000 bit 76543210 end[7:0] accessrrrrrrrr reset00000000
63 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.11 coresight rom table memory type name: memtype offset: 0x1fcc reset: 0x0000000x property: - z bits 31:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? smemp: system memory present this bit indicates whether system memory is present on the bus that connects to the rom table. this bit is set at powerup if the device is not protected indicating that the system memory is accessible from a debug adapter. this bit is cleared at powerup if the device is protected i ndicating that the system memory is not accessible from a debug adapter. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 smemp accessrrrrrrrr reset0000000x
64 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.12 peripheral identification 4 name: pid4 offset: 0x1fd0 reset: 0x00000000 property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:4 ? fkbc[3:0]: 4kb count these bits will always return zero when read, indi cating that this debug component occupies one 4kb block. z bits 3:0 ? jepcc[3:0]: jep-106 continuation code these bits will always return zero when read, indicating a atmel device. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 fkbc[3:0] jepcc[3:0] accessrrrrrrrr reset00000000
65 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.13 peripheral identification 0 name: pid0 offset: 0x1fe0 reset: 0x000000d0 property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? partnbl[7:0]: part number low these bits will always return 0xd0 when read, indi cating that this device implements a dsu module instance. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 partnbl[7:0] accessrrrrrrrr reset11010000
66 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.14 peripheral identification 1 name: pid1 offset: 0x1fe4 reset: 0x000000fc property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:4 ? jepidcl[3:0]: low part of the jep-106 identity code these bits will always return 0xf when read, indica ting a atmel device (atmel jep-106 identity code is 0x1f). z bits 3:0 ? partnbh[3:0]: part number high these bits will always return 0xc when read, indica ting that this device implements a dsu module instance. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 jepidcl[3:0] partnbh[3:0] accessrrrrrrrr reset11111100
67 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.15 peripheral identification 2 name: pid2 offset: 0x1fe8 reset: 0x00000009 property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:4 ? revision[3:0]: revision number revision of the peripheral. starts at 0x0 and increments by one at both major and minor revisions. z bit 3 ? jepu: jep-106 identity code is used this bit will always return one when read, indicating that jep-106 code is used. z bits 2:0 ? jepidch[2:0]: jep-106 identity code high these bits will always return 0x1 when read, indicating an atmel device (atmel jep-106 identity code is 0x1f). bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 revision[3:0] jepu jepidch[2:0] accessrrrrrrrr reset00001001
68 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.16 peripheral identification 3 name: pid3 offset: 0x1fec reset: 0x00000000 property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:4 ? revand[3:0]: revision number these bits will always return 0x0 when read. z bits 3:0 ? cusmod[3:0]: arm cusmod these bits will always return 0x0 when read. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 revand[3:0] cusmod[3:0] accessrrrrrrrr reset00000000
69 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.17 component identification 0 name: cid0 offset: 0x1ff0 reset: 0x0000000d property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? preambleb0[7:0]: preamble byte 0 these bits will always return 0xd when read. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 preambleb0[7:0] accessrrrrrrrr reset00001101
70 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.18 component identification 1 name: cid1 offset: 0x1ff4 reset: 0x00000010 property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:4 ? cclass[3:0]: component class these bits will always return 0x1 when read indicating t hat this arm coresight component is rom table (refer to the arm debug interface v5 architecture specification at http://www.arm.com ). z bits 3:0 ? preamble[3:0]: preamble these bits will always return 0x0 when read. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 cclass[3:0] preamble[3:0] accessrrrrrrrr reset00010000
71 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.19 component identification 2 name: cid2 offset: 0x1ff8 reset: 0x00000005 property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? preambleb2[7:0]: preamble byte 2 these bits will always return 0x05 when read. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 preambleb2[7:0] accessrrrrrrrr reset00000101
72 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.13.20 component identification 3 name: cid3 offset: 0x1ffc reset: 0x000000b1 property: - z bits 31:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? preambleb3[7:0]: preamble byte 3 these bits will always return 0xb1 when read. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 preambleb3[7:0] accessrrrrrrrr reset10110001
73 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 13. clock system this chapter only aims to summarize the clock distributi on and terminology in the sam d20 device. it will not explain every detail of its configuration. for in-depth documentation, see the referenced module chapters. 13.1 clock distribution figure 13-1. clock distribution the clock system on the sam d20 consists of: z clock sources , controlled by sysctrl z a clock source is the base clock signal used in the system. example clock sources are the internal 8mhz oscillator (osc8m), external crystal oscillator (xosc) and the digital frequency locked loop (dfll48m). z generic clock controller (gclk) which controls the clock distribution system, made up of: z generic clock generators : a programmable prescaler, that can use any of the system clock sources as its source clock. gclkgen[0] also called gclk_main, is the clock feeding the power manager. the power manager generates main clock. z generic clocks : typically the clock input of a peripheral on the system. the generic clocks, through the generic clock multiplexer, can use any of the generic clock generators as its clock source. multiple instances of a peripheral will typically have a separate generic clock for each instance. the output from generic clock multiplexer 0 is used as reference input for dfll48m. here dfll48m should not be used as a source for generic clock generator x, which feeds the generic clock multiplexer 0. z power manager (pm) z the pm controls synchronous clocks on the system. this includes the cpu, bus clocks (apb, ahb) as well as the synchronous (to the cpu) user interfaces of the peripherals. it contains clock masks that can turn on/off the user interface of a peripheral as well as prescalers for the cpu and bus clocks. figure 13-2 shows an example where sercom0 is clocked by the dfll48m in open loop mode. the dfll48m is enabled, the generic clock generator 1 uses the dfll48m as its clock source, and the generic clock 13, also called gclk_sercom0_core, that is connected to sercom0 uses generator 1 as its source. the sercom0 interface, clocked by clk_sercom0_apb, has been unmasked in the apbc mask register in the pm. s y sc tr l gc lk g eneric c loc k g enerator 1 g eneric c lock g enerator x g eneric c lock g enerator 0 g eneric c lock multiplexer 0 ( dfll48m re f erence ) main c lock c ontrolle r pm a hb/apb system clocks osc 8m osc 32k osculp32 k xosc3 2k dfll4 8 m xosc g eneric c lock multiplexer y g eneric c loc k multiplexer 1 peri p heral 0 p er i p h era l z generic clocks
74 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 13-2. example of sercom clock 13.2 synchronous and asynchronous clocks as the cpu and the peripherals can be clocked from different clock sources, possibly with widely different clock speeds, some peripheral accesses by the cpu needs to be synchronized between the different clock domains. in these cases the peripheral includes a syncbusy status flag that can be used to check if a sync operation is in progress. as the nature of the synchronization might vary between different peripheral s, detailed description for each peripheral can be found in the sub-chapter ?synchronization? for eac h peripheral where this is necessary. in the datasheet references to synchronous clocks are referr ing to the cpu and bus clocks, while asynchronous clocks are clock generated by generic clocks. 13.3 register synchronization 13.3.1 overview all peripherals are composed of one digital bus interface, wh ich is connected to the apb or ahb bus and clocked using a corresponding synchronous clock, and one core clock, which is clocked using a generic clock. access between these clock domains must be synchronized. as this mechanism is implemented in hardware the synchronization process takes place even if the clocks domains are clocked from the same source and on the same frequency. all registers in the bus interface are accessible without synchronization. all core registers in the generic clock domain must be synchronized when written. some core registers must be synchroniz ed when read. registers that need synchronization has this denoted in each individual register descrip tion. two properties are used: write- synchronization and read-synchronization. a common synchronizer is used for all registers in one peripheral, as shown in figure 13-3 . therefore, only one register per peripheral can be synchronized at a time. sysctrl dfll48m g eneric c lock g enerator 1 g eneric c lock multiplexer 13 sercom 0 main clock controller pm gclk_sercom0_apb gclk_sercom0_core gclk
75 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 13-3. synchronization 13.3.2 write-sy nchronization the write-synchronization is triggered by a write to any generic clock core register. the synchronization busy bit in the status register (status.syncbusy) will be set when the write-synchronization starts and cleared when the write- synchronization is complete. refer to ?synchronization delay? on page 77 for details on the synchronization delay. when the write-synchronization is ongoing (status.syncbusy is one), any of the following actions will cause the peripheral bus to stall until the synchronization is complete: z writing a generic clock core register z reading a read-synchronized core register z reading the register that is being written (and thus triggered the synchronization) core registers without read-synchronization will remain st atic once they have been written and synchronized, and can be read while the synchronization is ongoing without causing the per ipheral bus to stall. apb registers can also be read while the synchronization is ongoing without causing the peripheral bus to stall. non synced reg intflag status readreq write-synced reg write-synced reg r/w-synced reg synchronizer sync syncbusy synchronous domain (clk_apb) asynchronous domain (generic clock) peripheral bus
76 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 13.3.3 read-synchronization reading a read-synchronized core register will cause the peripheral bus to stall immediately until the read- synchronization is complete. the synchronization busy bit in the status register (statu s.syncbusy) will be set when the read-synchronization starts and cleared w hen the read-synchronization is complete. refer to ?synchronization delay? on page 77 for details on the synchronization delay. note that reading a read-synchronized core register whil e status.syncbusy is one will cause the peripheral bus to stall twice; first because of the ongoing synchronization, and then again because reading a read-synchronized core register will cause the peripheral bus to stall immediately. 13.3.4 completion of synchronization the user can either poll status.syncbusy or use the sync hronisation ready interrupt (if available) to check when the synchronization is complete. it is also possible to perform the next read/write operation and wait, as this next operation will be started once the previous write/read operation is synchronized and/or complete. 13.3.5 read request the read request functionality is only available to per ipherals that have the read request register (readreq) implemented. refer to the register description of individual peripheral chapters for details. to avoid forcing the peripheral bus to stall when reading r ead-synchronized core registers, the read request mechanism can be used. 13.3.5.1 basic read request writing a one to the read request bit in the read request register (readreq.rreq) will request read- synchronization of the register specified in t he address bits in rea dreq (readreq.addr) and set status.syncbusy. when read-synchr onization is complete, status.s yncbusy is cleared. the read- synchronized value is then available for reading without delay until readreq.rreq is written to one again. the address to use is the offset to the peripheral's base address of the register that should be synchronized. 13.3.5.2 continuous read request writing a one to the read continuously bit in re adreq (readreq.rcont) will force continuous read- synchronization of the register specified in readreq.addr . the latest value is always available for reading without stalling the bus, as the synchronization mechanism is continuously synchronizing the given value. syncbusy is set for the first synchronization, but not for the subsequent synchronizations. if another synchronization is attempted, i.e. by executing a write-operation of a write-syn chronized register, the read request will be stopped, and will have to be manually restarted. note that continuous read-synchronization is paused in sleep modes where the generic clock is not running. this means that a new read request is required if the value is needed immediately after exiting sleep. 13.3.6 write-synchroniz ation of ctrl.enable writing to the enable bit in the control register (ctr l.enable) will also trigger write-synchronization and set status.syncbusy. ctrl.enabl e will read its new value immediately af ter being written. the synchronisation ready interrupt (if available) cannot be used for enable write-synchronization. when the enable write-synchronization is o ngoing (status.syncbusy is one), attemp t to do any of the following will cause the peripheral bus to stall until the enable synchronization is complete: z writing a core register z writing an apb register z reading a read-synchronized core register apb registers can be read while the enable write-synchronizati on is ongoing without causing the peripheral bus to stall.
77 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 13.3.7 software reset write-synchronization writing a one to the software reset bit in ctrl (ctrl.swrst) will also trigger write-synchronization and set status.syncbusy. when writing a one to the ctrl.swrst bit it will immediately read as one. ctrl.swrst and status.syncbusy will be cleared by hardware when the peripheral has been reset. writing a zero to the ctrl.swrst bit has no effect. the synchronisation ready in terrupt (if available) cannot be used for software reset write-synchronization. when the software reset is in progress (status.syncbu sy and ctrl.swrst are one), attempt to do any of the following will cause the peripheral bus to stall until the software reset synchronization and the reset is complete: z writing a core register z writing an apb register z reading a read-synchronized register apb registers can be read while the software reset is being write-synchronized without causing the peripheral bus to stall. 13.3.8 synchronization delay the synchronization will delay the write or read a ccess duration by a delay d, given by the equation: where is the period of the generic clock and is the period of the peripheral bus clock. a normal peripheral bus register access duration is . 13.4 enabling a peripheral to enable a peripheral clocked by a generic clock, the following parts of the system needs to be configured: z a running clock source. z a clock from the generic clock generator must be configured to use one of the running clock sources, and the generator must be enabled. z the generic clock, through the generic clock multiplexer, that connects to the peripheral needs to be configured with a running clock from the generic clock generator, and the generic clock must be enabled. z the user interface of the peripheral needs to be unmasked in the pm. if this is not done the peripheral registers will read as all 0?s and any writes to the peripheral will be discarded. 13.5 on-demand, clock requests figure 13-4. clock request routing all the clock sources in the system can be run in an on-demand mode, where the clock source is in a stopped state when no peripherals are requesting the clock source. clock requests propagate from the peripheral, via the gclk, to the clock source. if one or more peripheral is using a clock source, the clock source will be started/kept running. as soon as the clock source is no longer needed and no peripheral have an active request the clock source will be stopped until requested again. for the clock request to reach the clock s ource, the peripheral, the generic clock and the clock from the generic clock generator in-between must be enabled. the time taken from a clock request being asserted to the clock 5 p gclk ? 2 p apb ? + d 6 p gclk ? 3 p apb ? + << p gclk p apb 2 p apb ? dfll48m g eneric c lock g enerator clock request g eneric c lock m ulti p lexer clock request p er iph era l clock request enable runstdby ondemand clken runstdby enable runstdby genen
78 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 source being ready is dependent on the clock source startup time , clock source frequency as well as the divider used in the generic clock generator. the total startup time from a cl ock request to the clock is available for the peripheral is: delay_start_max = clock source startup time + 2 * cl ock source periods + 2 * divided clock source periods delay_start_min = clock source startup time + 1 * clock source period + 1 * divided clock source period the delay for shutting down the clock source when there is no longer an active request is: delay_stop_min = 1 * divided clock source period + 1 * clock source period delay_stop_max = 2 * divided clock source periods + 2 * clock source periods the on-demand principle can be disabled individually for each clock source by clearing the ondemand bit located in each clock source controller. the clock is always running whatever is the clock request. this has the effect to remove the clock source startup time at the cost of the power consumption. in standby mode, the clock request mechanism is still worki ng if the modules are configured to run in standby mode (runstdby bit). 13.6 power consumption vs speed due to the nature of the asynchronous clocking of the peripher als there are some considerations that needs to be taken if either targeting a low-power or a fast-acting system. if cl ocking a peripheral with a very low clock, the active power consumption of the peripheral will be lower. at the same time the synchronization to the synchronous (cpu) clock domain is dependent on the peripheral clock speed, and will be longer with a slower peripheral clock; giving lower response time and more time waiting for the synchronization to complete. 13.7 clocks after reset on any reset the synchronous clocks start to their initial state: z osc8m is enabled and divided by 8 z gclk_main uses osc8m as source z cpu and bus clocks are undivided on a power reset the gclk starts to their initial state: z all generic clock generators disabled except: z the generator 0 (gclk_main) using osc8m as source, with no division z the generator 2 using osculp32k as source, with no division z all generic clocks disabled except: z the wdt generic clock using the generator 2 as source on a user reset the gclk starts to their initial state, except for: z generic clocks that are write-locked (wrtlock is written to one prior to reset or the wdt generic clock if the wdt always-on at power on bit set in the nvm user row) z the generic clock dedicated to the rtc if the rtc generic clock is enabled on any reset the clock sources are reset to their initial state except the 32khz clock sources which are reset only by a power reset.
79 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14. gclk ? generic clock controller 14.1 overview several peripherals may require specific clock frequencies to operate correctly. the generic clock controller consists of number of generic clock generators and generic clock multiplexers that can provide a wide range of clock frequencies. the generic clock generators can be set to use different external and internal clock sources. the selected clock can be divided down in the generic clock generator. the outputs from the generic clock generators are used as clock sources for the generic clock multiplexers, which select one of the s ources to generate a generic clock (gclk_peripheral), as shown in figure 14-2 . the number of generic clocks, m, depends on how many peripherals the device has. 14.2 features z provides generic clocks z wide frequency range z clock source for the generator can be changed on the fly 14.3 block diagram the generic clock controller can be seen in the clocking diagram, which is shown in figure 14-1 . figure 14-1. device clocking diagram the generic clock controller block diagram is shown in figure 14-2 . g clk _ i o g eneric clock generato r osc8m osc3 2k oscu lp 3 2k x osc32 k s ysctrl c lock d ivider & m as k e r c loc k g at e g eneric c lock multiplexe r gc lk_periphera l p eripheral s g eneri c c l oc k co ntr o lle r pm gclk _ mai n d fll4 8 m xosc
80 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 14-2. generic clock controller block diagram (1) note: 1. if the genctrl.src=gclkin the gclk_io is set as an input. 14.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 14.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 14.5.1 i/o lines using the generic clock controller?s i/o lines requires the i/o pins to be configured. refer to ?port? on page 280 for details. 14.5.2 power management the generic clock controller can operate in all sleep modes, if required. refer to table 15-4 for details on the different sleep modes. 14.5.3 clocks the generic clock controller bus clock (clk_gclk_apb) can be enabled and disabled in the power manager, and the default state of clk_gclk_apb can be found in the peripheral clock masking section in apbamask . generic clock generator 0 gc lk_i o [0] ( i/o input) c lock d ivider & maske r c lock s ources gclkgen [ 0 ] gc lk_i o [1] ( i/o input ) gc lk g en[1] g clk _ io [ n ] ( i /o input ) gc lk g en[n] clock g at e g eneric c lock multiplexer 0 gclk_peripheral[0] clock g at e g eneric c lock multiplexer 1 c lock g at e g eneric clock multi p lexer m gc lk g en[n:0] gc lk_main gc lk_i o [1 ] ( i /o output ) gc lk_i o [0 ] (i/o output ) gclk _ io [ n ] ( i /o output ) g eneric c lock g enerator 1 c lock divider & maske r g eneric c lock g enerator n c lock d ivider & m as k er gclk_peripheral[1] gclk_peripheral[m] signal name type description gclk_io[n:0] digital i/o source clock when input generic clock when output
81 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.5.4 interrupts not applicable. 14.5.5 events not applicable. 14.5.6 debug operation not applicable. 14.5.7 register access protection all registers with write-access are optionally write-pr otected by the peripheral access controller (pac). write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode or the cpu reset is extended, all write-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 14.5.8 analog connections not applicable. 14.6 functional description 14.6.1 principle of operation the gclk module is comprised of eight generic clock generators sourcing m generic clock multiplexers. a clock source selected as input to one of the generic clock generators can be used directly, or it can be prescaled in the generic clock generator before the generator output is used as i nput to one or more of the generic clock multiplexers. a generic clock multiplexer provides a generic clock to a per ipheral (gclk_peripheral). a generic clock can act as the clock to one or several of peripherals. 14.6.2 basic operation 14.6.2.1 initialization before a generic clock is enabled, the clock source of its generic clock generator should be enabled. the generic clock must be configured as outlined by the following steps: 1. the generic clock generator division factor must be set by performing a single 32-bit write to the generic clock generator division register (gendiv): z the generic clock generator that will be selected as the source of the generic clock must be written to the id bit group (gendiv.id). z the division factor must be written to the div bit group (gendiv.div) refer to gendiv register for details. 2. the generic clock generator must be enabled by performing a single 32-bit write to the generic clock generator control register (genctrl): z the generic clock generator that will be selected as the source of the generic clock must be written to the id bit group (genctrl.id) z the generic clock generator must be enabled by writing a one to the genen bit (genctrl.genen) refer to genctrl register for details. 3. the generic clock must be configured by performing a singl e 16-bit write to the generic clock control register (clkctrl):
82 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z the generic clock that will be configured must be written to the id bit group (clkctrl.id) z the generic clock generator used as the source of the generic clock must be written to the gen bit group (clkctrl.gen) refer to clkctrl register for details. 14.6.2.2 enabling, disabling and resetting the gclk module has no enable/disable bit to enable or disable the whole module. the gclk is reset by writing a one to the software reset bit in the control register (ctrl.swrst). all registers in the gclk will be reset to their initial state except for generic clocks and associated generators that have their write lock bit written to one. refer to ?configuration lock? on page 84 for details. 14.6.2.3 generic clock generator each generic clock generator (gclkgen) can be set to r un from one of eight different clock sources except gclkgen[1] which can be set to run from one of seven sour ces. gclkgen[1] can act as source to the other generic clock generators but can not act as source to itself. each generic clock generator gclkgen[x] can be connected to one specific gclk_io[x] pin. the gclk_io[x] can be set to act as source to gclkgen[x] or gclk_io[x] can be set up to output the clock generated by gclkgen[x]. the selected source (gclkgensrc see figure 14-3 ) can optionally be divided. each generic clock generator can be independently enabled and disabled. each gclkgen clock can then be used as a clock source for the generic clock multiplexers. each generic clock is allocated to one or several peripherals. gclkgen[0], is used as gclk_main for the synchronous clock controller inside the power manager. refer to ?pm ? power manager? on page 101 for details on the synchronous clock generation. figure 14-3. generic clock generator 14.6.2.4 enabling a generic clock generator a generic clock generator is enabled by writing a one to the generic clock generator enable bit in the generic clock generator control register (genctrl.genen). 14.6.2.5 disabling a generic clock generator a generic clock generator is disabled by writing a zero to genctrl.genen. when genctrl.genen is read as zero, the gclkgen clock is disabled and clock gated. 14.6.2.6 selecting a clock source for the generic clock generator each generic clock generator can individually select a clock source by writing to the source select bit group in genctrl (genctrl.src). changing from one clock source, a, to another clock source, b, can be done on the fly. if gc lk_i o [x] d ivide r c loc k g at e gc lk g en[x ] c lock s ource s 0 1 genctrl.divse l g en c trl. g enen g endiv.di v g enctrl.sr c gc lk g en s r c gc lk g en s r c
83 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 clock source b is not ready, the generic clock generator will continue running with clock source a. as soon as clock source b is ready, however, the generic clock generator will switch to it. during the switching, the generic clock generator holds clock requests to clock sources a and b and then releases the clock source a request when the switch is done. the available clock sources are device dependent (usually the crystal oscillators, rc oscillators, pll and dfll clocks). gclkgen[1] can be used as a common source for all t he generic clock generators except generic clock generator 1. 14.6.2.7 changing clock frequency the selected generic clock generator source, genclksrc can optionally be divided by writing a division factor in the division factor bit group in the generic clock gener ator division register (gendiv.div). depending on the value of the divide selection bit in genctrl (genctrl.divsel), it can be interpreted in two ways by the integer divider. note that the number of div bits for each generic clock generator is device dependent. refer to table 14-9 for details. 14.6.2.8 duty cycle when dividing a clock with an odd division factor, the duty-cycle will not be 50/50. writing a one to the improve duty cycle bit in genctrl (genctrl.idc) will result in a 50/50 duty cycle. 14.6.2.9 generic clock output on i/o pins each generic clock generator's output can be directed to a gclk_io pin. if the output enable bit in genctrl (genctrl.oe) is one and the generic clock generator is ena bled (genctrl.genen is one), the generic clock generator requests its clock source and the gclkgen clock is output to a gclk_io pin. if genctrl.oe is zero, gclk_io is set according to the output off value bit. if the output off value bit in genctrl (genctrl.oov) is zero, the output clock will be low when generic clock generator is tu rned off. if genctrl.oov is one, the output clock will be high when generic clock generator is turned off. in standby mode, if the clock is output (genctrl.oe is one) , the clock on the gclk_io pin is frozen to the oov value if the run in standby bit in genctrl (genctrl.runstdb y) is zero. if genctrl.runstdby is one, the gclkgen clock is kept running and output to gclk_io. 14.6.3 generic clock figure 14-4. generic clock multiplexer 14.6.3.1 enabling a generic clock before a generic clock is enabled, one of the generic clock generators must be selected as the source for the generic clock by writing to clkctrl.gen. the clock source selection is individually set for each generic clock. when a generic clock generator has been selected, the generic cl ock is enabled by writing a one to the clock enable bit in clkctrl (clkctrl.clken). the clkctrl.clken bi t must be synchronized to the generic clock domain. clkctrl.clken will continue to read as its prev ious state until the synchronization is complete. c loc k g at e gclk_peripheral c lkctrl.gen c lk c trl. c lken gclkgen [ 0 ] gc lk g en[1] gc lk g en[2] gclkgen [ n ]
84 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.6.3.2 disabling a generic clock a generic clock is disabled by writing a zero to clkctrl. clken. the syncbusy bit will be cleared when this write- synchronization is complete. clkctrl.clken will continue to read as its previous state until the synchronization is complete. when the generic clock is disabled, the generic clock is clock gated. 14.6.3.3 selecting a clock source for the generic clock when changing a generic clock source by writing to clkctrl. gen, the generic clock must be disabled before being re- enabled with the new clock source setting. this prevents glitches during the transition: a. write a zero to clkctrl.clken b. wait until clkctrl.clken reads as zero c. change the source of the generic clock by writing clkctrl.gen d. re-enable the generic clock by writing a one to clkctrl.clken 14.6.3.4 configuration lock the generic clock configuration is locked for further writ e accesses by writing the write lock bit (wrtlock) in the clkctrl register. all writes to the clkctrl register will be ignored. it can only be unlocked by a power reset. the generic clock generator sources of a locked generic clock are also locked. the corresponding genctrl and gendiv are locked, and can be unlocked only by a power reset. there is one exception concerning the gclkgen[0]. as it is used as gclk_main, it can not be locked. it is reset by any reset to startup with a known configuration. the swrst can not unlock the registers. 14.6.4 additional features 14.6.4.1 indirect access the generic clock generator control and division regist ers (genctrl and gendiv) and the generic clock control register (clkctrl) are indirectly addressed as shown in figure 14-5 . figure 14-5. gclk indirect access writing these registers is done by setting the corresponding id bit group. to read a register, the user must write the id of the channel, i, in the corresponding register. the value of the register for the corresponding id is available in the user interface by a read access. for example, the sequence to read the genctrl register of generic clock generator i is: a. do an 8-bit write of the i value to genctrl.id b. read genctrl genctr l g endiv c lk c tr l g en c trl.id= i g endiv.id=i clkctrl.id= j u ser interface genctr l g endiv g eneric c lock g enerator [i ] c lk c tr l g eneric clock[ j ]
85 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.6.4.2 generic clock enable after reset the generic clock controller must be able to provide a generic clock to some specific peripherals after a reset. that means that the configuration of the generic clock generators and generic clocks after reset is device-dependent. refer to table 14-7 and table 14-8 for details on genctrl reset. refer to table 14-11 and table 14-12 for details on gendiv reset. refer to table 14-3 and table 14-4 for details on clkctrl reset. 14.6.5 sleep mode operation 14.6.5.1 sleepwalking the gclk module supports the sleepwalking feature. du ring a sleep mode where the generic clocks are stopped, a peripheral that needs its generic clock to execute a process must request it from the generic clock controller. the generic clock controller will receive this request and then determine which generic clock generator is involved and which clock source needs to be awakened. it then wakes up the clock source, enables the generic clock generator and generic clock stages successively and delivers the generic clock to the peripheral. 14.6.5.2 run in standby mode in standby mode, the gclk can continuously output the generic clock generator output to gclk_io. refer to ?generic clock output on i/o pins? on page 83 for details. 14.6.6 synchronization due to the asynchronicity between clk_gclk_apb and gc lkgensrc some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following registers need synchronization when written: z generic clock generator control register (genctrl) z generic clock generator division register (gendiv) z control register (ctrl) write-synchronization is denoted by the write-sync hronization property in the register description. refer to ?register synchronization? on page 74 for further details.
86 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.7 register summary offset name bit pos. 0x0 ctrl 7:0 swrst 0x1 status 7:0 syncbusy 0x2 clkctrl 7:0 id[5:0] 0x3 15:8 wrtlock clken gen[3:0] 0x4 genctrl 7:0 id[3:0] 0x5 15:8 src[4:0] 0x6 23:16 runstdby divsel oe oov idc genen 0x7 31:24 0x8 gendiv 7:0 id[3:0] 0x9 15:8 div[7:0] 0xa 23:16 div[15:8] 0xb 31:24
87 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 81 for details. some registers require synchronization when read and/or wr itten. synchronization is denoted by the write-synchronized or the read-synchronized property in each individual register description. refer to ?synchronization? on page 85 for details.
88 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.8.1 control name: ctrl offset: 0x0 reset: 0x00 property: write-protected, write-synchronized z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: there is a reset operation ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the gclk to their initial state after a power reset, except for generic clocks and associated generators that have their wrtlock bit in clkctrl read as one. refer to table 14-7 for details on genctrl reset. refer to table 14-11 for details on gendiv reset. refer to table 14-3 for details on clkctrl reset. due to synchronization, there is a delay from writing ctrl.swrst until the reset is complete. ctrl.swrst and status.syncbusy will both be cleared when the reset is complete. bit76543210 swrst accessrrrrrrrr/w reset00000000
89 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.8.2 status name: status offset: 0x1 reset: 0x00 property: ? z bit 7 ? syncbusy: synchronization busy status this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit76543210 syncbusy accessrrrrrrrr reset00000000
90 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.8.3 generic clock control this register allows the user to configure one of the generic cl ocks, as specified in the clkctrl.id bit group. to write to the clkctrl register, do a 16-bit write with all configurations and the id. to read the clkctrl register, first do an 8-bit write to t he clkctrl.id bit group with the id of the generic clock whose configuration is to be read, and then read the clkctrl register. name: clkctrl offset: 0x2 reset: 0x0000 property: write-protected z bit 15 ? wrtlock: write lock when this bit is written, it will lock further writes to the generic clock pointed by the clkctrl.id. the generic clock generator pointed by clkctrl.gen and t he gendiv.div will also be locked. one exception to this is generic clock generator 0, which cannot be locked. 0: the generic clock and the associated generic clock generator and division factor are not locked. 1: the generic clock and the associated generic clock generator and division factor are locked. z bit 14 ? clken: clock enable this bit is used to enable and disable a generic clock. 0: the generic clock is disabled. 1: the generic clock is enabled. z bits 13:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 11:8 ? gen[3:0]: generic clock generator these bits select the generic clock generator to be used as the source of a generic clock. the value of the gen bit group versus generic clock generator is shown in table 14-1 . bit151413121110 9 8 wrtlock clken gen[3:0] access r/w r/w r r r/w r/w r/w r/w reset00000000 bit76543210 id[5:0] access r r r/w r/w r/w r/w r/w r/w reset00000000
91 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:0 ? id[5:0]: generic clock selection id these bits select the generic clock that will be configured. t he value of the id bit group versus module instance is shown in table 14-2 . table 14-1. generic clock generator value description 0x0 generic clock generator 0 0x1 generic clock generator 1 0x2 generic clock generator 2 0x3 generic clock generator 3 0x4 generic clock generator 4 0x5 generic clock generator 5 0x6 generic clock generator 6 0x7 generic clock generator 7 0x8-0xf reserved table 14-2. generic clock selection id value description 0x00 dfll48m reference 0x01 wdt 0x02 rtc 0x03 eic 0x04 evsys_channel_0 0x05 evsys_channel_1 0x06 evsys_channel_2 0x07 evsys_channel_3 0x08 evsys_channel_4 0x09 evsys_channel_5 0x0a evsys_channel_6 0x0b evsys_channel_7 0x0c sercomx_slow 0x0d sercom0_core 0x0e sercom1_core
92 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 a power reset will reset the clkctrl register for all ids, including the rtc. if the wrtlock bit of the corresponding id is zero and the id is not the rtc, a user reset will reset the clkctrl register for this id. after a power reset, the reset value of the clkctrl register versus module instance is as shown in table 14-3 . after a user reset, the reset value of the clkctrl register versus module instance is as shown in table 14-4 . 0x0f sercom2_core 0x10 sercom3_core 0x11 sercom4_core 0x12 sercom5_core 0x13 tc0,tc1 0x14 tc2,tc3 0x15 tc4,tc5 0x16 tc6,tc7 0x17 adc 0x18 ac_dig 0x19 ac_ana 0x1a dac 0x1b ptc 0x1c-0x3f reserved table 14-3. clkctrl reset value after a power reset module instance reset value after a power reset clkctrl.gen clkctrl.clken clkctrl.wrtlock rtc 0x00 0x00 0x00 wdt 0x02 0x01 if wdt enable bit in nvm user row written to one 0x00 if wdt enable bit in nvm user row written to zero 0x01 if wdt always-on bit in nvm user row written to one 0x00 if wdt always-on bit in nvm user row written to zero others 0x00 0x00 0x00 table 14-2. generic clock selection id (continued)
93 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 14-4. clkctrl reset value after a user reset module instance reset value after a user reset clkctrl.gen clkctrl.clken clkctrl.wrtlock rtc 0x00 if wrtlock=0 and clken=0 no change if wrtlock=1 or clken=1 0x00 if wrtlock=0 and clken=0 no change if wrtlock=1 or clken=1 no change wdt 0x02 if wrtlock=0 no change if wrtlock=1 if wrtlock=0 0x01 if wdt enable bit in nvm user row written to one 0x00 if wdt enable bit in nvm user row written to zero if wrtlock=1 no change no change others 0x00 if wrtlock=0 no change if wrtlock=1 0x00 if wrtlock=0 no change if wrtlock=1 no change
94 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.8.4 generic clock generator control this register allows the user to configure one of the generic clock generators, as specified in the genctrl.id bit group. to write to the genctrl register, do a 32-bi t write with all configurations and the id. to read the genctrl register, first do an 8-bit write to the genctrl.id bit group with the id of the generic clock generator those configuration is to be read, and then read the genctrl register. name: genctrl offset: 0x4 reset: 0x00010600 (1) property: write-protected, write-synchronized note: 1. this is the reset value for generator with id =0. see table 14-7 for reset value of other generators. z bits 31:22 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 21 ? runstdby: run in standby this bit is used to keep the generic clock generator running when it is configured to be output to its dedicated gclk_io pin. if genctrl.oe is zero, this bit has no e ffect and the generic clock generator will only be running if a peripheral requires the clock. 0: the generic clock generator is stopped in standby and the gclk_io pin state (one or zero) will be dependent on the setting in genctrl.oov. 1: the generic clock generator is kept running and out put to its dedicated gclk_io pin during standby mode. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 runstdby divsel oe oov idc genen access r r r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 src[4:0] access r r r r/w r/w r/w r/w r/w reset00000000 bit76543210 id[3:0] access r r r r r/w r/w r/w r/w reset00000000
95 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 20 ? divsel: divide selection this bit is used to decide how the clock source used by the generic clock generator will be divided. if the clock source should not be divided, the divsel bit must be zero and the gendiv.div value for the corresponding generic clock generator must be zero or one. 0: the generic clock generator equals the cl ock source divided by gendiv.div. 1: the generic clock generator equals the cloc k source divided by 2^(gendiv.div+1). z bit 19 ? oe: output enable this bit is used to enable output of the generated clock to gclk_io when gclk_io is not selected as a source in the genclk.src bit group. 0: the generic clock generator is not output. 1: the generic clock generator is output to the corresp onding gclk_io, unless the corresponding gclk_io is selected as a source in the genclk.src bit group. z bit 18 ? oov: output off value this bit is used to control the value of gclk_io when gclk_io is not selected as a source in the genclk.src bit group. 0: the gclk_io will be zero when the generic clock generator is turned off or when the oe bit is zero. 1: the gclk_io will be one when the generic clock gener ator is turned off or when the oe bit is zero. z bit 17 ? idc: improve duty cycle this bit is used to improve the duty cycle of the generic clock generator when odd division factors are used. 0: the generic clock generator duty cycle is not 50/50 for odd division factors. 1: the generic clock generator duty cycle is 50/50. z bit 16 ? genen: generic clock generator enable this bit is used to enable and disable the generic clock generator. 0: the generic clock generator is disabled. 1: the generic clock generator is enabled. z bits 15:13 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 12:8 ? src[4:0]: source select these bits define the clock source to be used as t he source for the generic clock generator, as shown in table 14- 5 .
96 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:0 ? id[3:0]: generic clock generator selection these bits select the generic clock generator that will be configured or read. the value of the id bit group versus which generic clock generator is configured is shown in table 14-6 . a power reset will reset the genctrl register for all ids, including the generic clock generator used by the rtc. if a generic clock generator id other than generic clock generator 0 is not a source of a ?locked? generic clock or a source of the rtc generic clock, a user reset will reset the genctrl for this id. after a power reset, the reset value of the genctrl register is as shown in table 14-7 . table 14-5. source select value name description 0x00 xosc xosc oscillator output 0x01 gclkin generator input pad 0x02 gclkgen1 generic clock generator 1 output 0x03 osculp32k osculp32k oscillator output 0x04 osc32k osc32k oscillator output 0x05 xosc32k xosc32k oscillator output 0x06 osc8m osc8m oscillator output 0x07 dfll48m dfll48m output 0x08-0x1f reserved reserved for future use table 14-6. generic clock generator selection value description 0x0 generic clock generator 0 0x1 generic clock generator 1 0x2 generic clock generator 2 0x3 generic clock generator 3 0x4 generic clock generator 4 0x5 generic clock generator 5 0x6 generic clock generator 6 0x7 generic clock generator 7 0x8-0xf reserved
97 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 after a user reset, the reset value of the genctrl register is as shown in table 14-8 . table 14-7. genctrl reset value after a power reset generic clock generator id reset value after a power reset generator clock source 0x00 0x00010600 osc8m 0x01 0x00000001 xosc 0x02 0x00010302 osculp32k 0x03 0x00000003 xosc 0x04 0x00000004 xosc 0x05 0x00000005 xosc 0x06 0x00000006 xosc 0x07 0x00000007 xosc table 14-8. genctrl reset value after a user reset generic clock generator id reset value after a user reset 0x00 0x00010600 0x01 0x00000001 if the generator is not used by the rt c and not a source of a 'locked' generic clock no change if the generator is used by the rtc or used by a gclk with a wrtlock as one 0x02 0x00010302 if the generator is not used by the rt c and not a source of a 'locked' generic clock no change if the generator is used by the rtc or used by a gclk with a wrtlock as one 0x03 0x00000003 if the generator is not used by the rt c and not a source of a 'locked' generic clock no change if the generator is used by the rtc or used by a gclk with a wrtlock as one 0x04 0x00000004 if the generator is not used by the rt c and not a source of a 'locked' generic clock no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x05 0x00000005 if the generator is not used by the rt c and not a source of a 'locked' generic clock no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x06 0x00000006 if the generator is not used by the rt c and not a source of a 'locked' generic clock no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x07 0x00000007 if the generator is not used by the rt c and not a source of a 'locked' generic clock no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one
98 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 14.8.5 generic clock generator division this register allows the user to configure one of the gener ic clock generators, as specified in the gendiv.id bit group. to write to the gendiv register, do a 32-bi t write with all configurations and the id. to read the gendiv register, first do an 8-bit write to the gendiv.id bit group with the id of the generic clock generator whose configuration is to be read, and then read the gendiv register. name: gendiv offset: 0x8 reset: 0x00000000 property: write-protected, write-synchronized z bits 31:24 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 23:8 ? div[15:0]: division factor these bits apply a division on each selected generic clo ck generator. the number of div bits each generator has can be seen in table 14-9 . writes to bits above the specified number will be ignored. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 div[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 div[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 id[3:0] access r r r r r/w r/w r/w r/w reset00000000
99 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:0 ? id[3:0]: generic clock generator selection these bits select the generic clock generator on which the division factor will be applied, as shown in table 14-10 . a power reset will reset the gendiv register for all ids, including the generic clock generator used by the rtc. if a generic clock generator id other than generic clock generator 0 is not a source of a ?locked? generic clock or a source of the rtc generic clock, a user reset will reset the gendiv for this id. after a power reset, the reset value of the gendiv register is as shown in table 14-11 . table 14-9. division factor generator division factor bits generic clock generator 0 8 division factor bits - div[7:0] generic clock generator 1 16 division factor bits - div[15:0] generic clock generators 2 5 division factor bits - div[4:0] generic clock generators 3 - 7 8 division factor bits - div[7:0] table 14-10. generic clock generator selection value description 0x0 generic clock generator 0 0x1 generic clock generator 1 0x2 generic clock generator 2 0x3 generic clock generator 3 0x4 generic clock generator 4 0x5 generic clock generator 5 0x6 generic clock generator 6 0x7 generic clock generator 7 0x8-0xf reserved
100 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 after a user reset, the reset value of the gendiv register is as shown in table 14-12 . table 14-11. gendiv reset value after a power reset generic clock generator id reset value after a power reset 0x00 0x00000000 0x01 0x00000001 0x02 0x00000002 0x03 0x00000003 0x04 0x00000004 0x05 0x00000005 0x06 0x00000006 0x07 0x00000007 table 14-12. gendiv reset value after a user reset generic clock generator id reset value after a user reset 0x00 0x00000000 0x01 0x00000001 if the generator is not used by the rtc no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x02 0x00000002 if the generator is not used by the rtc no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x03 0x00000003 if the generator is not used by the rtc no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x04 0x00000004 if the generator is not used by the rtc no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x05 0x00000005 if the generator is not used by the rtc no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x06 0x00000006 if the generator is not used by the rtc no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one 0x07 0x00000007 if the generator is not used by the rtc no change if the generator is used by the rtc or used by a generic clock with a wrtlock as one
101 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15. pm ? power manager 15.1 overview the power manager (pm) controls the reset, clock generation and sleep modes of the microcontroller. utilizing a main clock chosen from a large number of clo ck sources from the gclk, the clock controller provides synchronous system clocks to the cpu and the modules c onnected to the ahb and the apbx bus. the synchronous system clocks are divided into a number of clock domains; one for the cpu and ahb and one for each apbx. any synchronous system clock can be changed at run-time during norma l operation. the clock domains can run at different speeds, enabling the user to save power by running peripherals at a relatively low clock frequency, while maintaining high cpu performance. in addition, the clock can be masked fo r individual modules, enabling the user to minimize power consumption. if for some reason the main clock stops oscillating, the clock failure detector allows switching the main clock to the safe osc8m clock. before entering the standby sleep mode the user must make sure that a significant amount of clocks and peripherals are disabled, so that the voltage regulator is not overl oaded. this is because during standby sleep mode the internal voltage regulator will be in low power mode. various sleep modes and clock gating are provided in order to fit power consumption requirements. this enables the microcontroller to stop unused modules to save power. in active mode, the cpu is executing application code. when the device enters a sleep mode, program execution is st opped and some modules and clock domains are automatically switched off by the pm according to the sleep mode. the application code decides which sleep mode to enter and when. interrupts from enabled peripherals and all enabled reset sources can restore the microcontroller from a sleep mode to active mode. the pm also contains a reset controller, which collects all possible reset sources. it issues a microcontroller reset and sets the device to its initial state, and allows the reset source to be identified by software. 15.2 features z reset control z reset the microcontroller and set it to an initial state according to the reset source z multiple reset sources z power reset sources: por, bod12, bod33 z user reset sources: external reset (reset ), watchdog timer reset, software reset z reset status register for reading the reset source from the application code z clock control z controls cpu, ahb and apb system clocks z multiple clock sources and division factor from gclk z clock prescaler with 1x to 128x division z safe run-time clock switching from gclk z module-level clock gating through maskable peripheral clocks z clock failure detector z power management control z sleep modes: idle, standby z sleepwalking support on gclk clocks
102 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.3 block diagram figure 15-1. pm block diagram 15.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 15.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 15.5.1 i/o lines not applicable. 15.5.2 power management not applicable. synchronous clock controller sleep mode controller reset controller cpu bod12 bod33 por wdt osc8m gclk reset sources peripherals reset clk_apb clk_ahb clk_cpu user reset power reset power manager cpu signal name type description reset digital input external reset
103 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.5.3 clocks the pm bus clock (clk_pm_apb) can be enabled and disabled in the power manager, and the default state of clk_pm_apb can be found in table 15-1 . if this clock is disabled in the power manager, it can only be re-enabled by a reset. a generic clock (gclk_main) is required to generate the main clock. the clock source for gclk_main is configured by default in the generic clock controller, and can be re-configured by the user if needed. refer to ?gclk ? generic clock controller? on page 79 for details. 15.5.3.1 main clock the main clock (clk_main) is the common source for the synchronous clocks. this is fed into the common 8-bit prescaler that is used to generate synchronous clocks to the cpu, ahb and apbx modules. 15.5.3.2 cpu clock the cpu clock (clk_cpu) is routed to the cpu. halting the cpu clock inhibits the cpu from executing instructions. 15.5.3.3 ahb clock the ahb clock (clk_ahb) is the root cl ock source used by peripherals requiring an ahb clock. the ahb clock is always synchronous to the cpu clock and has the same frequency, but may run even when the cpu clock is turned off. a clock gate is inserted from the common ahb cl ock to any ahb clock of a peripheral. 15.5.3.4 apbx clocks the apbx clock (clk_apbx) is the r oot clock source used by modules requi ring a clock on the apbx bus. the apbx clock is always synchronous to the cpu clock, but can be di vided by a prescaler, and will run even when the cpu clock is turned off. a clock gater is inserted from the common apb clock to any apbx clock of a module on apbx bus. 15.5.4 interrupts the interrupt request line is connected to the interrupt controller. using the pm interrupt requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 15.5.5 events not applicable. 15.5.6 debug operation when the cpu is halted in debug mode, the pm continues normal operation. in sleep mode, the clocks generated from the pm are kept running to allow the debugger accessing any modules. as a consequence, power measurements are not possible in debug mode. 15.5.7 register access protection all registers with write access are optionally write-protec ted by the peripheral access controller (pac), except the following registers: z interrupt flag register (intflag). refer to intflag for details z reset cause register (rcause). refer to rcause for details write-protection is denoted by the write-protection property in the register description. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 15.5.8 analog connections not applicable.
104 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.6 functional description 15.6.1 principle of operation 15.6.1.1 synchronous clocks the gclk_main clock from gclk module pr ovides the source for the main clock, which is the common root for the synchronous clocks for the cpu and apbx modules. the main clock is divided by an 8-bit prescaler, and each of the derived clocks can run from any tapping off this prescaler or the undivided main clock, as long as f cpu f apbx . the synchronous clock source can be changed on the fly to respond to varying load in the application. the clocks for each module in each synchronous clock domain can be individually ma sked to avoid power consumption in inactive modules. depending on the sleep mode, some clock domains can be turned off (see table 15-4 on page 109 ). 15.6.1.2 reset controller the reset controller collects the various reset sources and generates reset for the device. the device contains a power- on-reset (por) detector, which keeps the system reset until power is stable. this eliminates the need for external reset circuitry to guarantee stable operation when powering up the device. 15.6.1.3 sleep mode controller in active mode, all clock domains are active, allowi ng software execution and peripheral operation. the pm sleep mode controller allows the user to choose between diff erent sleep modes depending on application requirements, to save power (see table 15-4 on page 109 ). 15.6.2 basic operation 15.6.2.1 initialization after a power-on reset, the pm is enabled and the reset cause (rcause - refer to rcause for details) register indicates the por source. the default clock source of the gclk_main clock is started and calibrated before the cpu starts running. the gclk_main clock is selected as the main clock without any division on the prescaler. the device is in the active mode. by default, only the necessary clocks are enabled (see table 15-1 ). 15.6.2.2 enabling, disabling and resetting the pm module is always enabled and can not be reset. 15.6.2.3 selecting the main clock source refer to ?gclk ? generic clock controller? on page 79 for details on how to configure the main clock source. 15.6.2.4 selecting the synchronous clock division ratio the main clock feeds an 8-bit prescaler, which can be used to generate the synchronous clocks. by default, the synchronous clocks run on the undivided main clock. the user can select a prescaler division for the cpu clock by writing the cpu prescaler selection bits in the cpu sele ct register (cpusel.cpudiv), resulting in a cpu clock frequency determined by this equation: similarly, the clock for the apbx can be divided by writi ng their respective registers (apbxsel.apbxdiv). to ensure correct operation, frequencies must be selected so that f cpu f apbx . also, frequencies must never exceed the specified maximum frequency for each clock domain. note that the ahb clock is always equal to the cpu clock. f cpu f main 2 cpudiv ---------------------- =
105 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 cpusel and apbxsel can be written without halting or dis abling peripheral modules. writing cpusel and apbxsel allows a new clock setting to be written to all synchronous clocks at the same time. it is possible to keep one or more clocks unchanged. this way, it is possible to, for example, scale the cpu speed according to the required performance, while keeping the apbx frequency constant. figure 15-2. synchronous clock selection and prescaler 15.6.2.5 clock ready flag there is a slight delay from when cpusel and apbxsel are written until the new clock setting becomes effective. during this interval, the clock ready flag in the interrupt flag status and clear register (intflag.ckrdy) will read as zero. if ckrdy in the intenset register is written to one, the power manager interrupt can be triggered when the new clock setting is effective. cpusel must not be re-written wh ile ckrdy is zero, or the system may become unstable or hang. 15.6.2.6 peripheral clock masking it is possible to disable or enable the clock for a peripheral in the ahb or apbx clock domain by writing the corresponding bit in the clock mask register (apbxmask - refer to apbamask for details) to zero or one. refer to table 15-1 for the default state of each of the peripheral clocks. clock gate clock gate prescaler sleep controller sleep mode clk_ahb clock gate clock gate clk_apba clock gate clock gate clk_apbc clock gate clock gate clk_apbb apbcdiv apbbdiv apbadiv clk_peripheral_ahb_0 clk_peripheral_ahb_1 clk_peripheral_ahb_n clk_peripheral_apba_0 clk_peripheral_apba_1 clk_peripheral_apba_n clk_peripheral_apbb_0 clk_peripheral_apbb_1 clk_peripheral_apbb_n clk_peripheral_apbc_0 clk_peripheral_apbc_1 clk_peripheral_apbc_n apbcmask apbbmask apbamask cpudiv ahbmask clk_cpu gclk osc8m gclk_main bkupclk clock gate clock gate clock gate clock gate clock gate clock gate clock gate clock gate clock gate clock failure detector clk_main
106 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 when the apb clock for a module is not provided its regist ers cannot be read or written. the module can be re-enabled later by writing the corresponding mask bit to one. a module may be connected to several clock domains (for instance, ahb and apb), in which case it will have several mask bits. note that clocks should only be switched off if it is certain that the module will not be used. switching off the clock for the nvm controller (nvmctrl) will cause a problem if the cpu needs to read from the flash memory. switching off the clock to the power manager (pm), which contains the mask registers, or the corresponding apbx bridge, will make it impossible to write the mask registers again. in this case, they can only be re-enabled by a system reset. 15.6.2.7 clock failure detector this mechanism allows the main clock to be switched automatically to the safe osc8m clock when the main clock source is considered off. this may happen for instance when an ex ternal crystal oscillator is selected as the clock source for the main clock and the crystal fails. the mechanism is to designed to detect, during a osculp32k clock period, at least one rising edge of the main clock. if no rising edge is seen, the clock is considered failed. the clock failure detector is enabled by writing a one to the clock failure detector enable bit in ctrl (cfden_ctrl). refer to ctrl for detailed information. as soon as the clock failure detector enable bit (ctrl.cfden) is one, the clock failure detector (cfd) will monitor the undivided main clock. when a clock failure is detected, the main clock automatically switches to the osc8m clock and the clock failure detector flag in the interrupt flag st atus and clear register (intflag.cfd) is set and the corresponding interrupt request will be generated if enabled. the bk upclk bit in the ctrl register is set by hardware table 15-1. peripheral clock default state peripheral clock default state clk_pac0_apb enabled clk_pm_apb enabled clk_sysctrl_apb enabled clk_gclk_apb enabled clk_wdt_apb enabled clk_rtc_apb enabled clk_eic_apb enabled clk_pac1_apb enabled clk_dsu_apb enabled clk_nvmctrl_apb enabled clk_port_apb enabled clk_pac2_apb disabled clk_sercomx_apb disabled clk_tcx_apb disabled clk_adc_apb enabled clk_ac_apb disabled clk_dac_apb disabled clk_ptc_apb disabled
107 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 to indicate that the main clock comes from osc8m. t he gclk_main clock source can be selected again by writing a zero to the ctrl.bkupclk bit. writing the bit does not fix the failure, however. note 1: the detector does not monitor while the main clock is te mporarily unavailable (startup time after a wake-up, etc.) or in sleep mode. the clock failure detector must be disabled before entering standby mode. note 2: the clock failure detector must not be enabled if the source of the main clock is not significantly faster than the osculp32k clock. for instance, if gclk_main is the internal 32khz rc, then the clock failure detector must be disabled. note 3: the osc8m internal oscillator should be enabled to allow the main clock switching to the osc8m clock. 15.6.2.8 reset controller the latest reset cause is available in rcause, and can be read during the application boot sequence in order to determine proper action. there are two groups of reset sources: z power reset: resets caused by an electrical issue. z user reset: resets caused by the application. the table below lists the parts of the device that are reset, depending on the reset type. the external reset is generated when pulling the reset pin low. this pin has an internal pull-up, and does not need to be driven externally during normal operation. the por, bod12 and bod33 reset sources are generated by their corresponding module in the system controller interface (sysctrl). the wdt reset is generated by the watchdog timer. the system reset request (sysresetreq) is a software reset generated by the cpu when asserting the sysresetreq bit located in the reset c ontrol register of the cpu (see the arm ? cortex ? technical reference manual on http://www.arm.com ). table 15-2. effects of the different reset events power reset user reset por, bod12, bod33 external reset wdt reset, sysresetreq rtc all the 32khz sources wdt with alwayson feature generic clock with wrtlock feature y n n debug logic y y n others y y y
108 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 15-3. reset controller 15.6.2.9 sleep mode controller sleep mode is activated by the wait for interrupt instru ction (wfi). the idle bits in the sleep mode register (sleep.idle) and the sleepdeep bit of the system control r egister of the cpu should be used as argument to select the level of the sleep mode. there are two main types of sleep mode: z idle mode: the cpu is stopped. optionally, some synchronous clock domains are stopped, depending on the idle argument. regulator operates in normal mode. z standby mode: all clock sources are stopped, except thos e where the runstdby bit is set. regulator operates in low-power mode. before entering standby mode the user must make sure that a significant amount of clocks and peripherals are disabled, so that the voltage regulator is not overloaded. notes: 1. asynchronous: interrupt generated on generic clock or external clock or external event. 2. synchronous: interrupt generated on the apb clock. reset controller bod12 bod33 por wdt reset reset sources rtc 32khz clock sources wdt with alwayson generic clock with wrtlock debug logic others cpu rcause table 15-3. sleep mode entry and exit table mode level mode entry wake-up sources idle 0 scr.sleepdeep = 0 sleep.idle=level wfi synchronous (2) (apb, ahb), asynchronous (1) 1 synchronous (apb), asynchronous 2 asynchronous standby scr.sleepdeep = 1 wfi asynchronous
109 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 idle mode the idle modes allow power optimization with the fastest wake-up time. the cpu is stopped. to further reduce power consumption, the user can disable the clocking of modules and clock sources by configuring the sleep.idle bit group. the module will be halted regardless of the bit settings of the mask registers in the power manager (pm.ahbmask, pm.apbxmask). regulator operates in normal mode. z entering idle mode: the idle mode is entered by ex ecuting the wfi instruction. additionally, if the sleeponexit bit in the arm cortex s ystem control register (scr) is se t, the idle mode will also be entered when the cpu exits the lowest priority isr. this mechanism can be useful for applications that only require the processor to run when an interrupt occurs. before entering the idle mode, the user must configure the idle mode configuration bit group and must write a zero to the scr.sleepdeep bit. z exiting idle mode: the processor wakes the system up when it detects the occurrence of any interrupt that is not masked in the nvic controller with sufficient priority to cause exception entry. the system goes back to the active mode. the cpu and affected modules are restarted. standby mode the standby mode allows achievi ng very low power consumption. in this mode, all clocks are stopped except those which are kept running if requested by a running module or have the ondemand bit set to zero. for example, the rtc can operat e in standby mode. in this case, its generic clock clock source will also be enabled. the regulator and the ram operate in low-power mode. a sleeponexit feature is also available. z entering standby mode: this mode is entered by executi ng the wfi instruction with the scr.sleepdeep bit of the cpu is written to 1. z exiting standby mode: any peripheral able to generate an asynchronous interrupt can wake up the system. for example, a module running on a generic clock can tri gger an interrupt. when the enabled asynchronous wake-up event occurs and the system is woken up, the device will either execute the interrupt service routine or continue the normal program execution according to the priority mask register (primask) configuration of the cpu. table 15-4. sleep mode overview sleep mode cpu clock ahb clock apb clock oscillators main clock regulator mode ram mode ondemand = 0 ondemand = 1 runstdby=0 runstdby=1 runstdby=0 runstdby=1 idle 0 stop run run run run run if requested run if requested run normal normal idle 1 stop stop run run run run if requested run if requested run normal normal idle 2 stop stop stop run run run if requested run if requested run normal normal standby stop stop stop stop run stop run if requested stop low power low power
110 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.6.3 sleepwalking sleepwalking is the capability for a device to temporarily wa keup clocks for peripheral to perform a task without waking- up the cpu in standby sleep mode. at the end of the sle epwalking task, the device can either be waken-up by an interrupt (from a peripheral involved in sleepwal king) or enter again into standby sleep mode. in atmel | smart sam d20 devices, sleepwalking is s upported only on gclk clocks by using the on-demand clock principle of the clock sources. refer to ?on-demand, clock requests? on page 77 for more details. 15.6.4 interrupts the peripheral has the following interrupt sources: z clock ready flag z clock failure detector each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear (intflag) register is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set (int enset) register, and disabled by writing a one to the corresponding bit in the interrupt enable clear (intenclr) r egister. an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the peripheral is reset. an interrupt flag is cleared by writing a one to the corresponding bit in the intflag register. each peripheral can have one interrupt request line per interrupt source or one common interrupt request line for all the interrupt sources. refer to ?nested vector interrupt controller? on page 25 for details. if the peripheral has one common interrupt request li ne for all the interrupt sources, the user must read the intflag register to determine which interrupt condition is present. 15.6.5 events not applicable. 15.6.6 sleep mode operation in all idle sleep modes, the power manager is still running on the selected main clock. in standdby sleep mode, the power manager is frozen and is able to go back to active mode upon any asynchronous interrupt.
111 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.7 register summary offset name bit pos. 0x00 ctrl 7:0 bkupclk cfden 0x01 sleep 7:0 idle[1:0] 0x02 reserved 0x03 reserved ? ? ? ? ? ? ? ? ? ? ? 0x06 reserved 0x07 reserved 0x08 cpusel 7:0 cpudiv[2:0] 0x09 apbasel 7:0 apbadiv[2:0] 0x0a apbbsel 7:0 apbbdiv[2:0] 0x0b apbcsel 7:0 apbcdiv[2:0] 0x0c reserved 0x0d reserved ? 0x12 reserved 0x13 reserved 0x14 ahbmask 7:0 nvmctrl dsu hpb2 hpb1 hpb0 0x15 15:8 0x16 23:16 0x17 31:24 0x18 apbamask 7:0 eic rtc wdt gclk sysctrl pm pac0 0x19 15:8 0x1a 23:16 0x1b 31:24 0x1c apbbmask 7:0 port nvmctrl dsu pac1 0x1d 15:8 0x1e 23:16 0x1f 31:24 0x20 apbcmask 7:0 sercom5 sercom4 sercom3 sercom2 sercom1 sercom0 evsys pac2 0x21 15:8 tc7 tc6 tc5 tc4 tc3 tc2 tc1 tc0 0x22 23:16 ptc dac ac adc 0x23 31:24 0x24 reserved 0x25 reserved ? ? ? ? ? ? ? ? ? ? ? 0x32 reserved
112 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x33 reserved 0x34 intenclr 7:0 cfd ckrdy 0x35 intenset 7:0 cfd ckrdy 0x36 intflag 7:0 cfd ckrdy 0x37 reserved 0x38 rcause 7:0 syst wdt ext bod33 bod12 por offset name bit pos.
113 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register, and the 8-bit hal ves of a 16-bit register can be accessed directly. exception for apbasel, apbbsel and apbcsel: these registers must onl y be accessed with 8-bit access. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 103 for details.
114 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.1 control name: ctrl offset: 0x00 reset: 0x00 property: write-protected z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? bkupclk: backup clock select this bit is set by hardware when a clock failure is detected. 0: the gclk_main clock is selected for the main clock. 1: the osc8m backup clock is selected for the main clock. z bit 3 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 2 ? cfden: clock failure detector enable 0: the clock failure detector is disabled. 1: the clock failure detector is enabled. z bits 1:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit 7 6 5 4 3 2 1 0 bkupclk cfden access r r r r/w r r/w r r reset 0 0 0 0 0 0 0 0
115 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.2 sleep mode name: sleep offset: 0x01 reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? idle[1:0]: id le mode configuration these bits select the idle mode configuration after a wfi instruction. bit76543210 idle[1:0] accessrrrrrrr/wr/w reset00000000 table 15-5. idle mode configuration idle[1:0] description 0x0 the cpu clock domain is stopped 0x1 the cpu and ahb clock domains are stopped 0x2 the cpu, ahb and apb clock domains are stopped 0x3 reserved
116 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.3 cpu clock select name: cpusel offset: 0x08 reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? cpudiv[2:0]: cpu prescaler selection these bits define the division ratio of the main clock prescaler (2 n ). bit 76543210 cpudiv[2:0] accessrrrrrr/wr/wr/w reset00000000 table 15-6. cpu clock frequency ratio cpudiv[1:0] description 0x0 divide by 1 0x1 divide by 2 0x2 divide by 4 0x3 divide by 8 0x4 divide by 16 0x5 divide by 32 0x6 divide by 64 0x7 divide by 128
117 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.4 apba clock select name: apbasel offset: 0x09 reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? apbadiv[2:0]: apba prescaler selection these bits define the division ratio of the apba clock prescaler (2 n ). bit76543210 apbadiv[2:0] access r r r r r r/w r/w r/w reset00000000 table 15-7. apba prescaler selection apbadiv[1:0] description 0x0 divide by 1 0x1 divide by 2 0x2 divide by 4 0x3 divide by 8 0x4 divide by 16 0x5 divide by 32 0x6 divide by 64 0x7 divide by 128
118 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.5 apbb clock select name: apbbsel offset: 0x0a reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? apbbdiv[2:0]: apbb prescaler selection these bits define the division ratio of the apbb clock prescaler (2 n ). bit76543210 apbbdiv[2:0] accessrrrrrr/wr/wr/w reset00000000 table 15-8. apbb prescaler selection apbbdiv[1:0] description 0x0 divide by 1 0x1 divide by 2 0x2 divide by 4 0x3 divide by 8 0x4 divide by 16 0x5 divide by 32 0x6 divide by 64 0x7 divide by 128
119 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.6 apbc clock select name: apbcsel offset: 0x0b reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? apbcdiv[2:0]: apbc prescaler selection these bits define the division ratio of the apbc clock prescaler (2 n ). bit76543210 apbcdiv[2:0] access r r r r r r/w r/w r/w reset00000000 table 15-9. apbc prescaler selection apbcdiv[1:0] description 0x0 divide by 1 0x1 divide by 2 0x2 divide by 4 0x3 divide by 8 0x4 divide by 16 0x5 divide by 32 0x6 divide by 64 0x7 divide by 128
120 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.7 ahb mask name: ahbmask offset: 0x14 reset: 0x0000001f property: write-protected z bits 31:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:0 ? nvmctrl, dsu, hpb2 , hpb1, hpb0: ahb clock enable for any bit: 0: the ahb clock for the corresponding module is stopped. 1: the ahb clock for the corresponding module is enabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 nvmctrl dsu hpb2 hpb1 hpb0 access r r r r/w r/w r/w r/w r/w reset00011111
121 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.8 apba mask name: apbamask offset: 0x18 reset: 0x0000007f property: write-protected z bits 31:7 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 6:0 ? eic, rtc, wdt, gclk, sysctrl, pm, pac0: apb clock enable for any bit: 0: the apba clock for the corresponding module is stopped. 1: the apba clock for the corresponding module is enabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 eic rtc wdt gclk sysctrl pm pac0 access r r/w r/w r/w r/w r/w r/w r/w reset01111111
122 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.9 apbb mask name: apbbmask offset: 0x1c reset: 0x0000001f property: write-protected z bits 31:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:0 ? port, nvmctrl, dsu, pac1: apb clock enable for any bit: 0: the apbb clock for the corresponding module is stopped. 1: the apbb clock for the corresponding module is enabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 port nvmctrl dsu pac1 access r r r r r/w r/w r/w r/w reset00011111
123 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.10 apbc mask name: apbcmask offset: 0x20 reset: 0x00010000 property: write-protected z bits 31:20 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 19:0 ? ptc, dac, ac, adc, tc7, tc6, tc5, tc4, tc3, tc2, tc1, tc0, sercom5, sercom4, sercom3, sercom2, sercom1, sercom 0, evsys, pac2: apb clock enable for any bit: 0: the apbc clock for the corresponding module is stopped. 1: the apbc clock for the corresponding module is enabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 ptc dac ac adc access r r r r r/w r/w r/w r/w reset00000001 bit151413121110 9 8 tc7 tc6 tc5 tc4 tc3 tc2 tc1 tc0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 sercom5 sercom4 sercom3 sercom2 sercom1 sercom0 evsys pac2 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
124 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.11 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interr upt enable set (intenset) register. name: intenclr offset: 0x34 reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? cfd: clock failure detector interrupt enable 0: the clock failure detector interrupt is disabled. 1: the clock failure detector interrupt is enabled and an interrupt request will be generated when the clock fail- ure detector interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the clock failure detector interrupt enable bit and the corresponding interrupt request. z bit 0 ? ckrdy: clock ready interrupt enable 0: the clock ready interrupt is disabled. 1: the clock ready interrupt is enabled and will generate an interrupt request when the clock ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the clock ready in terrupt enable bit and the corresponding interrupt request. bit76543210 cfd ckrdy accessrrrrrrr/wr/w reset00000000
125 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.12 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear (intenclr) register. name: intenset offset: 0x35 reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? cfd: clock failure detector interrupt enable 0: the clock failure detector interrupt is disabled. 1: the clock failure detector interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the clock failure detector interrupt enable bit and enable the clock failure detec- tor interrupt. z bit 0 ? ckrdy: clock ready interrupt enable 0: the clock ready interrupt is disabled. 1: the clock ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the clock ready interrupt enable bit and enable the clock ready interrupt. bit76543210 cfd ckrdy accessrrrrrrr/wr/w reset00000000
126 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.13 interrupt flag status and clear name: intflag offset: 0x36 reset: 0x00 property: ? z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? cfd: clock failure detector this flag is cleared by writing a one to the flag. this flag is set on the next cycle after a clock failure detector occurs and will generate an interrupt request if intenclr/set.cfd is one. writing a zero to this bit has no effect. writing a one to this bit clears the clock failure detector interrupt flag. z bit 0 ? ckrdy: clock ready this flag is cleared by writing a one to the flag. this flag is set when the synchronous cpu and apbx clocks have frequencies as indicated in the cpusel and apbxsel registers, and will generate an interrupt if intenclr/set.ckrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the clock ready interrupt flag. bit76543210 cfd ckrdy accessrrrrrrr/wr/w reset00000000
127 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 15.8.14 reset cause name: rcause offset: 0x38 reset: latest reset source property: ? z bit 7 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 6 ? syst: system reset request this bit is set if a system reset request has been performed. refer to the cortex processor documentation for more details. z bit 5 ? wdt: watchdog reset this flag is set if a watchdog timer reset occurs. z bit 4 ? ext: external reset this flag is set if an external reset occurs. z bit 3 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 2 ? bod33: brown out 33 detector reset this flag is set if a bod33 reset occurs. z bit 1 ? bod12: brown out 12 detector reset this flag is set if a bod12 reset occurs. z bit 0 ? por: power-on reset this flag is set if a por occurs. bit76543210 syst wdt ext bod33 bod12 por accessrrrrrrrr reset0xxx0xxx
128 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16. sysctrl ? system controller 16.1 overview the system controller (sysctrl) provides a user interfac e to the clock sources, brown out detectors, on-chip voltage regulator and voltage reference of the device. through the interface registers, it is possible to enable, disable, calibrate and monitor the sysctrl sub-peripherals. all sub-peripheral statuses are collected in the po wer and clocks status register (pclksr - refer to pclksr ). they can additionally trigger interrupts upon status changes via the intenset ( intenset ), intenclr ( intenclr ) and intflag ( intflag ) registers. additionally, bod33 interrupts can be used to wake up the device from standby mode upon a programmed brown-out detection. 16.2 features z 0.4-32mhz crystal oscillator (xosc) z tunable gain control z programmable start-up time z crystal or external input clock on xin i/o z 32.768khz crystal oscillator (xosc32k) z automatic or manual gain control z programmable start-up time z crystal or external input clock on xin32 i/o z 32.768khz high accuracy internal oscillator (osc32k) z frequency fine tuning z programmable start-up time z 32.768khz ultra low power internal oscillator (osculp32k) z ultra low power, always-on oscillator z frequency fine tuning z calibration value loaded from flas h factory calibration at reset z 8mhz internal oscillator (osc8m) z fast startup z output frequency fine tuning z 4/2/1mhz divided output frequencies available z calibration value loaded from flas h factory calibration at reset z digital frequency locked loop (dfll48m) z internal oscillator with no external components z 48mhz output frequency z operates standalone as a high-frequency programmable oscillator in open loop mode z operates as an accurate frequency multiplier against a known frequency in closed loop mode z 3.3v brown-out detector (bod33) z programmable threshold z threshold value loaded from flas h user calibration at startup z triggers resets or interrupts z operating modes: z continuous mode z sampled mode for low power applications (programmable refresh frequency) z hysteresis z voltage reference system (vref) z bandgap voltage generator with programmable calibration value z temperature sensor z bandgap calibration value loaded from flash factory calibration at startup
129 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.3 block diagram figure 16-1. sysctrl block diagram 16.4 signal description the i/o lines are automatically selected when xosc or xosc32k are enabled. signal name types description xin analog input multipurpose crystal oscillator or external clock generator input xout analog output external multipurpose crystal oscillator output xin32 analog input 32khz crystal oscillator or external clock generator input xout32 analog output 32khz crystal oscillator output xosc xosc 32k osc3 2k oscu lp 3 2 k o sc8 m d fll48m vo lta ge r eferen ce s y s tem osc illat o r s co ntr o l p o we r mo nit o r co ntr ol v o lta g e referen c e co ntr o l s tatu s ( pclksr re g ister ) i nterrupt s g enerat or bod3 3 interrupt s s ysctr l
130 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 16.5.1 i/o lines i/o lines are configured by sysctrl when either xosc or xosc32k are enabled, and need no user configuration. 16.5.2 power management the sysctrl can continue to operate in any sleep mode wher e the selected source clock is running. the sysctrl interrupts can be used to wake up the device from sleep m odes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 16.5.3 clocks the sysctrl gathers controls for all device oscillators and provides clock sources to the generic clock controller (gclk). the available clock sources are: xosc , xosc32k, osc32k, osculp32k, osc8m and dfll48m. the sysctrl bus clock (clk_sysctrl_apb) can be enabled and disabled in the power manager, and the default state of clk_sysctrl_apb can be found in the peripheral clock masking section in the ?pm ? power manager? on page 101 . the clock used by bod33in sampled mode is asynchronous to the user interface clock (clk_sysctrl_apb). likewise, the dfll48m control logic uses the dfll oscillator output, which is also asynchronous to the user interface clock (clk_sysctrl_apb). due to this asynchronicity, writ es to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 139 for further details. 16.5.4 interrupts the interrupt request line is connected to the interrupt cont roller. using the sysctrl interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 16.5.5 debug operation when the cpu is halted in debug mode, the sysctrl continues normal operation. if the sysctrl is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. if a debugger connection is detected by the system, bod33 reset will be blocked. 16.5.6 register access protection all registers with write-access are optionally write-protect ed by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register (intflag - refer to intflag ) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all wr ite-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 16.5.7 analog connections the 32.768khz crystal must be connected between the xin32 and xout32 pins, and the 0.4-32mhz crystal must be connected between the xin and xout pins, along with any required load capacitors. for details on recommended oscillator characteristics and capacitor load, refer to the ?electrical characteristics? on page 563 for details.
131 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.6 functional description 16.6.1 principle of operation xosc, xosc32k, osc32k, osculp32k, osc8m, dfll48m, bo d33, and vref are confi gured via sysctrl control registers. through this interface, the sub-peripherals are enabled, disabled or have their calibration values updated. the power and clocks status register gathers different status signals coming from the sub-peripherals controlled by the sysctrl. the status signals can be used to generate system in terrupts, and in some cases wake up the system from standby mode, provided the corresponding interrupt is enabled. the oscillator must be enabled to run. the oscillator is enabled by writing a one to the enable bit in the respective oscillator control register, and disabled by writing a zero to the oscillator control register. in idle mode, the default operation of the oscillator is to run only when requested by a peripheral. in standby mode, the default operation of the oscillator is to stop. this behavior can be changed by the user, see below for details. the behavior of the oscillators in the different sleep modes is shown in table 16-1 on page 131 to force an oscillator to always run in idle mode, and not only when requested by a peripheral, the oscillator ondemand bit must be written to zero. the default value of this bit is one, and thus the default operation in idle mode is to run only when requested by a peripheral. to force the oscillator to run in standby mode, the runstdby bit must be written to one. the oscillator will then run in standby mode when requested by a peripheral (ondemand is one). to force an oscillator to always run in standby mode, and not only when requested by a peripheral, the onde mand bit must be written to zero and runstdby must be written to one. table 16-2 on page 131 shows the behavior in the different sleep modes, depending on the settings of ondemand and runstdby. note that this does not apply to the osculp32k osci llator, which is always running and cannot be disabled. table 16-1. behavior of the oscillators oscillator idle 0, 1, 2 standby xosc run on request stop xosc32k run on request stop osc32k run on request stop osculp32k run run osc8m run on request stop dfll48m run on request stop table 16-2. behavior in the different sleep modes sleep mode ondemand runstdby behavior idle 0, 1, 2 0 x run idle 0, 1, 2 1 x run when requested by a peripheral standby 0 0 stop standby 0 1 run standby 1 0 stop standby 1 1 run when requested by a peripheral
132 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.6.2 external multipurpose crystal oscillator (xosc) operation the xosc can operate in two different modes: z external clock, with an external clock signal connected to the xin pin z crystal oscillator, with an external 0.4-32mhz crystal the xosc can be used as a clock source for generic clock generators, as described in the ?gclk ? generic clock controller? on page 79 . at reset, the xosc is disabled, and the xin/xout pins can be used as general purpose i/o (gpio) pins or by other peripherals in the system. when xosc is enabled, the operating mode determines the gpio usage. when in crystal oscillator mode, the xin and xout pins are controlled by the sysctrl, and gpio functions are overridden on both pins. when in external clock mode, only the xin pin will be overridden and controlled by the sysctrl, while the xout pin can still be used as a gpio pin. the xosc is enabled by writing a one to the enable bit in the external multipurpose crystal oscillator control register (xosc.enable). to enable the xosc as a crystal osci llator, a one must be written to the xtal enable bit (xosc.xtalen). if xosc.xtalen is zero , external clock input will be enabled. when in crystal oscillator mode (xosc.xtalen is one), the external multipurpose crystal oscillator gain (xosc.gain) must be set to match the external crystal oscillator frequency. if the external multipurpose crystal oscillator automatic amplitude gain control (xosc.ampgc) is one, the oscillato r amplitude will be automatically adjusted, and in most cases result in a lower power consumption. the xosc will behave differently in different sleep modes based on the settings of xosc.runstdby, xosc.ondemand and xosc.enable: after a hard reset, or when waking up from a sleep mode where the xosc was disabled, the xosc will need a certain amount of time to stabilize on the correct frequency. this start-up time can be configured by changing the oscillator start-up time bit group (xosc. startup) in the external multipurpose crystal oscillator control register. during the start-up time, the oscillator output is masked to ensure that no unstable clock propagates to the digital logic. the external multipurpose crystal oscillator ready bit in the power and clock status register (pclks r.xoscrdy) is set when the user-selected startup time is over. an interrupt is generated on a zero-to-one transition on pclksr.xoscrdy if the external multipurpose crystal oscillator ready bit in the interrupt enable set register (intenset.xoscrdy) is set. note: do not enter standby mode when an oscillator is in startup: wait for the oscxrdy bit in sysctrl.pclksr r egister to be set before going into standby mode. 16.6.3 32khz external crystal oscillator (xosc32k) operation the xosc32k can operate in two different modes: z external clock, with an external clock signal connected to xin32 z crystal oscillator, with an external 32.768khz crystal connected between xin32 and xout32 xosc.runstdby xosc.ondemand xosc.enable sleep behavior - - 0 disabled 0 0 1 always run in idle sleep modes. disabled in standby sleep mode. 0 1 1 only run in idle sleep modes if requested by a peripheral. disabled in standby sleep mode. 1 0 1 always run in idle and standby sleep modes. 1 1 1 only run in idle or standby sleep modes if requested by a peripheral.
133 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the xosc32k can be used as a source for generic clock generators, as described in the ?gclk ? generic clock controller? on page 79 . at power-on reset (por) the xosc32k is disabled, and t he xin32/xout32 pins can be used as general purpose i/o (gpio) pins or by other peripherals in the system. w hen xosc32k is enabled, the operating mode determines the gpio usage. when in crystal oscillator mode, xin32 and xout32 are controlled by the sysctrl, and gpio functions are overridden on both pins. when in external clock mode, onl y the xin32 pin will be overridden and controlled by the sysctrl, while the xout32 pin can still be used as a gpio pin. the external clock or crystal oscillator is enabled by writ ing a one to the enable bit (xosc32k.enable) in the 32khz external crystal oscillator control register. to enable the xo sc32k as a crystal oscillator, a one must be written to the xtal enable bit (xosc32k.xtalen) . if xosc32k.xtalen is zero, external clock input will be enabled. the oscillator is disabled by writing a zero to the enable bit (xosc32k.enable) in the 32khz external crystal oscillator control register while keeping the other bits unchanged. writi ng to the xosc32k.enable bit while writing to other bits may result in unpredictable behavior. the oscillator remains enabled in all sleep modes if it has been enabled beforehand. the start-up time of the 32khz external crystal osci llator is selected by writing to the oscillator start-up time bit group (xosc32k.startup) in the in the 32khz ex ternal crystal oscillator control register. the sysctrl masks the oscillator output during the start-up time to ensure that no unstable clock propagates to the digital logic. the 32khz external crystal oscillator ready bit (pclksr.xosc32krdy) in the power and clock status register is set when the user-selected startup time is over. an interrupt is generated on a zero-to-one transition of pclksr.xosc32krdy if the 32khz external crystal oscill ator ready bit (intenset.xosc32krdy) in the interrupt enable set register is set. as a crystal oscillator usually requires a very long start-up time (up to one second), the 32khz external crystal oscillator will keep running across resets, except for power-on reset (por). xosc32k can provide two clock outputs when connected to a crystal. the xosc32k has a 32.768khz output enabled by writing a one to the 32khz external crystal oscillator 32khz output enable bit (xosc32k.en32k) in the 32khz external crystal oscillator control register. the xosc32k also has a 1.024khz clock output enabled by writing a one to the 32khz external crystal oscillator 1khz output enable bit (xosc32k.en1k) in the external 32khz crystal oscillator control register. xosc32k.en32k and xosc32k.en1k are onl y usable when xin32 is connected to a crystal, and not when an external digital clock is applied on xin32. note: do not enter standby mode when an oscillator is in startup: wait for the oscxrdy bit in sysctrl.pclksr r egister to be set before going into standby mode. 16.6.4 32khz internal osc illator (osc32k) operation the osc32k provides a tunable, low-speed and low-power clock source. the osc32k can be used as a source for the generic clock generators, as described in the ?gclk ? generic clock controller? on page 79 . the osc32k is disabled by default. the osc32k is enabled by writing a one to the 32khz internal oscillator enable bit (osc32k.enable) in the 32khz internal oscillator control regi ster. it is disabled by writing a zero to osc32k.enable. the osc32k has a 32.768khz output enabled by writing a one to the 32khz internal oscillator 32khz output enable bit (osc32k.en32k). the osc32k also has a 1.024khz clock output enabled by writing a one to the 32khz internal oscillator 1khz output enable bit (osc32k.en1k). the frequency of the osc32k oscillator is controlled by the value in the 32khz internal oscillator calibration bits (osc32k.calib) in the 32khz internal oscillator control register. the osc32k.calib value must be written by the user. flash factory calibration values are stored in the nvm software calibration area (refer to ?nvm software calibration area mapping? on page 23 ). when writing to the calibration bits, the user must wait for the pclksr.osc32krdy bit to go high before t he value is committed to the oscillator.
134 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.6.5 32khz ultra low power internal oscillator (osculp32k) operation the osculp32k provides a tunable, low-speed and ultra- low-power clock source. the osculp32k is factory- calibrated under typical voltage and temperature conditions. the osculp32k should be preferred to the osc32k whenever the power requirements are prevalent over frequency stability and accuracy. the osculp32k can be used as a source for the generic clock generators, as described in the ?gclk ? generic clock controller? on page 79 . the osculp32k is enabled by default after a power-on reset (por) and will always run except during por. the osculp32k has a 32.768khz output and a 1.024khz output that are always running. the frequency of the osculp32k oscillator is controlled by the value in the 32khz ultra low power internal oscillator calibration bits (osculp32k.calib) in the 32khz ultr a low power internal oscillator control register. osculp32k.calib is automatically loaded from flash factory calibration during startup, and is used to compensate for process variation, as described in the ?electrical characteristics? on page 563 . the calibration value can be overridden by the user by writi ng to osculp32k.calib. 16.6.6 8mhz internal oscillator (osc8m) operation osc8m is an internal oscillator operating in open-loop m ode and generating an 8mhz frequency. the osc8m is factory- calibrated under typical voltage and temperature conditions. osc8m is the default clock source that is used after a pow er-on reset (por). the osc8m can be used as a source for the generic clock generators, as described in the ?gclk ? generic clock controller? on page 79 , as well as function as the backup clock if a main clock failure is detected. in order to enable osc8m, the oscillator enable bit in the osc8m control register (osc8m .enable) must be written to one. osc8m will not be enabled until osc8m.enable is set. in order to disable osc8m, osc8m.enable must be written to zero. osc8m will not be disabled until osc8m is cleared. the frequency of the osc8m oscillator is controlled by the va lue in the calibration bits (osc8m.calib) in the osc8m control register. calib is automatically loaded from flash factory calibration dur ing startup, and is used to compensate for process variation, as described in the ?electrical characteristics? on page 563 . the user can control the oscillation frequency by writing to the frequency range (frange) and calibration (calib) bit groups in the 8mhz rc oscillator control register (o sc8m). it is not recommended to update the frange and calib bits when the osc8m is enabled. as this is in open-loop mode, the frequency will be voltage, temperature and process dependent. refer to the ?electrical characteristics? on page 563 for details. osc8m is automatically switched off in certain sleep m odes to reduce power consumption, as described in the ?pm ? power manager? on page 101 . 16.6.7 digital frequency locked loop (dfll48m) operation the dfll48m can operate in both open-loop mode and closed-l oop mode. in closed-loop mode, a low-frequency clock with high accuracy can be used as the reference clock to get high accuracy on the output clock (clk_dfll48m). the dfll48m can be used as a source for the generic clock generators, as described in the ?gclk ? generic clock controller? on page 79 . 16.6.7.1 basic operation open-loop operation after any reset, the open-loop mode is selected. when operating in open-loop mode, the output frequency of the dfll48m will be determined by the values written to the dfll coarse value bit group and the dfll fine value bit group (dfllval.coarse and dfllval.fi ne) in the dfll value register. it is possible to change the values of dfllval.coarse and dfllval.fine and thereby the output frequency of the dfll48m output clock, clk_dfll48m, while the dfll48m is enabled and in use. clk_dfll48m is ready to be used when pclksr.dfllrdy is set after enabling the dfll48m.
135 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 closed-loop operation in closed-loop operation, the output frequency is continu ously regulated against a reference clock. once the multiplication factor is set, the oscillator fine tuning is aut omatically adjusted. the dfll48m must be correctly configured before closed-loop operation can be enabled. after enabling t he dfll48m, it must be configured in the following way: 1. enable and select a reference clock (clk_dfll48m_r ef). clk_dfll48m_ref is generic clock channel 0 (dfll48m_reference). refer to ?gclk ? generic clock controller? on page 79 for details. 2. select the maximum step size allowed in finding the coarse and fine values by writing the appropriate values to the dfll coarse maximum step and dfll fine ma ximum step bit groups (dfllmul.cstep and dfll- mul.fstep) in the dfll multiplier register. a small st ep size will ensure low overshoot on the output frequency, but will typically result in longer lock times. a high val ue might give a large overshoot, but will typically provide faster locking. dfllmul.cstep and dfllmul.fstep shoul d not be higher than 50% of the maximum value of dfllval.coarse and dfllval.fine, respectively. 3. select the multiplication factor in the dfll multiply fa ctor bit group (dfllmul.mul) in the dfll multiplier regis- ter. care must be taken when choosing dfllmul.mul so that the output frequency does not exceed the maximum frequency of the dfll. if the target frequency is below the minimum frequency of the dfll48m, the out- put frequency will be equal to the dfll minimum frequency. 4. start the closed loop mode by writing a one to the df ll mode selection bit (dfllctrl.mode) in the dfll con- trol register. the frequency of clk_dfll48m (f clkdfll48m ) is given by: where f clkdfll48mref is the frequency of the reference clo ck (clk_dfll48m_ref). dfllval.coarse and dfllval.fine are read-only in closed-loop mode, and are cont rolled by the frequency tuner to meet user specified frequency. in closed-loop mode, the value in dfllval.coars e is used by the frequency tuner as a starting point for coarse. writing dfllval.coarse to a value close to the fi nal value before entering closed-loop mode will reduce the time needed to get a lock on coarse. frequency locking the locking of the frequency in closed-loop mode is divided into two stages. in the first, coarse stage, the control logic quickly finds the correct value for dfllval.coarse and sets the output frequency to a value close to the correct frequency. on coarse lock, the dfll locked on coarse value bit (pclksr.dflllockc) in the power and clocks status register will be set. in the second, fine stage, the control logic tunes the value in dfllval.fine so that the output frequency is very close to the desired frequency. on fine lock, the dfll locked on fine value bit (pclksr.dflllockf) in the power and clocks status register will be set. interrupts are generated by both pclksr.dflllockc and pclksr.dflllockf if intenset.dfllockc or intenset.dfllockf are written to one. clk_dfll48m is ready to be used when the dfll ready bi t (pclksr.dfllrdy) in the power and clocks status register is set, but the accuracy of the output frequency depends on which locks are set. for lock times, refer to the ?electrical characteristics? on page 563 . frequency error measurement the ratio between clk_dfll48m_ref and clk48m_dfll is m easured automatically when the dfll48m is in closed- loop mode. the difference between this ratio and the value in dfllmul.mul is stored in the dfll multiplication ratio difference bit group(dfllval.diff) in the dfll value regi ster. the relative error on clk_dfll48m compared to the target frequency is calculated as follows: f clkdfll 48 m dfllmul mul f clkdfll 48 mref ? = error diff mul -------------- =
136 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 drift compensation if the stable dfll frequency bit (dfllctrl.stable) in the df ll control register is zero, the frequency tuner will automatically compensate for drift in the clk_dfll48m without losing either of the locks. this means that dfllval.fine can change after every measurement of cl k_dfll48m. if the dfllval.fine value overflows or underflows due to large drift in temperature and/or volt age, the dfll out of bounds bit (pclksr.dflloob) in the power and clocks status register will be set. after an out of bounds error condition, the user must rewrite dfllmul.mul to ensure correct clk_ dfll48m frequency. an interrupt is generated on a zero-to-one transition on pclksr.dflloob if the dfll out of b ounds bit (intenset.dflloob) in the inte rrupt enable set register is set. this interrupt will also be triggered if the tuner is not able to lock on the correct coarse value. reference clock stop detection if clk_dfll48m_ref stops or is running at a ve ry low frequency (slower than clk_dfll48m/(2 * mul max )), the dfll reference clock stopped bit (pclksr.dfllrcs) in the po wer and clocks status register will be set. detecting a stopped reference clock can take a long time, on the order of 2 17 clk_dfll48m cycles. when the reference clock is stopped, the dfll48m will operate as if in open-loop mode. closed-loop mode operation will automatically resume if the clk_dfll48m_ref is restarted. an interrupt is generat ed on a zero-to-one transition on pclksr.dfllrcs if the dfll reference clock stopped bit (intenset.dfllrcs) in the interrupt enable set register is set. 16.6.7.2 additional features dealing with delay in the dfll in closed-loop mode the time from selecting a new clk_dfll48m frequency until this frequency is output by the dfll48m can be up to several microseconds. if the value in dfllmul.mul is small, this can lead to instability in the dfll48m locking mechanism, which can prevent the dfll48m from achieving locks. to avoid this, a chill cycle, during which the clk_dfll48m frequency is not measured, can be enabled. the chill cycle is enabled by default, but can be disabled by writing a one to the dfll chill cycle disable bit (dfllctrl.ccd is) in the dfll control register. enabling chill cycles might double the lock time. another solution to this problem consists of using less strict lock requirements. this is called quick lock (ql), which is also enabled by default, but it can be disabled by writing a o ne to the quick lock disable bit (dfllctrl.qldis) in the dfll control register. the quick lock might lead to a larger spread in the output frequency than chill cycles, but the average output frequency is the same. wake from sleep modes dfll48m can optionally reset its lock bits when it is disabled. this is configured by the lose lock after wake bit (dfllctrl.llaw) in the dfll control register. if dfllc trl.llaw is zero, the dfll48m will be re-enabled and start running with the same configuration as before being disabled, even if the reference clock is not available. the locks will not be lost. when the reference clock has restarted, the fine tracking will quickly compensate for any frequency drift during sleep if dfllctrl.stable is zero. if dfllctrl.ll aw is one when the dfll is turned off, the dfll48m will lose all its locks, and needs to regain these through the full lock sequence. accuracy there are three main factors that determine the accuracy of f clkdfll48m . these can be tuned to obtain maximum accuracy when fine lock is achieved. z fine resolution: the frequency step between two fine values. this is relatively smaller for high output frequencies. z resolution of the measurement: if the resolution of the measured f clkdfll48m is low, i.e., the ratio between the clk_dfll48m frequency and the clk_dfll48m_ref frequency is small, then the dfll48m might lock at a frequency that is lower than the targeted frequency. it is recommended to use a reference clock frequency of 32khz or lower to avoid this issue for low target frequencies. z the accuracy of the reference clock. 16.6.8 3.3v brown-out detector operation the 3.3v bod monitors the 3.3v vddana supply (bod33). it supports continuous or sampling modes.
137 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the threshold value action (reset the device or generate an interrupt), the hysteresis configuration, as well as the enable/disable settings are loaded from flash user calibrati on at startup, and can be overridden by writing to the corresponding bod33 register bit groups. 16.6.8.1 3.3v brown-out detector (bod33) the 3.3v brown-out detector (bod33) monitors the vdda na supply and compares the voltage with the brown-out threshold level set in the bod33 level bit group (bod33.leve l) in the bod33 register. the bod33 can generate either an interrupt or a reset when vddana cro sses below the brown-out threshold level. the bod33 detection status can be read from the bod33 detection bit (pclksr.bod33det) in the power and clocks status register. at startup or at power-on reset (por), the bod33 regist er values are loaded from the flash user row. refer to ?non- volatile memory (nvm) user row mapping? on page 22 for more details. 16.6.8.2 continuous mode when the bod33 mode bit (bod33.mode) in the bod33 register is written to zero and the bod33 is enabled, the bod33 operates in continuous mode. in this mode, the bod33 is continuously monitoring the vddana supply voltage. continuous mode is the default mode for bod33. 16.6.8.3 sampling mode the sampling mode is a low-power mode where the bod33 is being repeatedly enabled on a sampling clock?s ticks. the bod33 will monitor the supply voltage for a short period of ti me and then go to a low-power disabled state until the next sampling clock tick. sampling mode is enabled by writing one to bod33.mode. the frequency of the clock ticks (f clksampling ) is controlled by the bod33 prescaler select bit group (bod33.psel) in the bod33 register. the prescaler signal (f clkprescaler ) is a 1khz clock, output from the32khz ultra low power oscillator, osculp32k. as the sampling mode clock is different from the apb clock domain, synchronization among the clocks is necessary. figure 16-2 shows a block diagram of the sampling mode. the bod33synchronization ready bits (pclksr.b33srdy) in the power and clocks status register show the synchroniza tion ready status of the synchronizer. writing attempts to the bod33 register are ignored while pclksr.b33srdy is zero. figure 16-2. sampling mode block diagram the bod33 clock enable bit (bod33.cen) in the bod 33 register should always be disabled before changing the prescaler value. to change the prescaler value for the bod33 during sampling mode, the following steps need to be taken: 1. wait until the pclksr.b33srdy bit is set. f clksampling f clkprescaler 2 psel 1 + () ------------------------------ = us er interfa ce r e g i s ter s ( apb clock domain ) p re sc ale r ( clk_prescale r domain ) s yn c hr o nizer p s el c en mo de enabl e c lk_apb c lk_pre sc aler c lk _ samplin g
138 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 2. write the selected value to the bod33.psel bit group. 16.6.8.4 hysteresis the hysteresis functionality can be used in both continuous and sampling mode. writing a one to the bod33 hysteresis bit (bod33.hyst) in the bod33 register will add hysteresis to the bod33 threshold level. 16.6.9 voltage reference system operation the voltage reference system (vref) consists of a b andgap reference voltage generator and a temperature sensor. the bandgap reference voltage generator is factory-calibrated under typical voltage and temperature conditions. at reset, the vref.cal register value is loaded from flash factory calibration. the temperature sensor can be used to get an absolute te mperature in the temperature range of cmin to cmax degrees celsius. the sensor will output a linear volt age proportional to the temperature. the output voltage and temperature range are located in the ?electrical characteristics? on page 563 . to calculate the temperature from a measured voltage, the following formula can be used: 16.6.9.1 user control of the voltage reference system to enable the temperature sensor, write a one the temperat ure sensor enable bit (vref.tsen) in the vref register. the temperature sensor can be redirected to the adc fo r conversion. the bandgap reference voltage generator output can also be routed to the adc if the bandgap output enabl e bit (vref.bgouten) in t he vref register is set. the bandgap reference voltage generator output level is deter mined by the calib bit group (vref.calib) value in the vref register.the default calibration value can be ove rridden by the user by writing to the calib bit group. 16.6.10 interrupts the sysctrl has the following interrupt sources: z xoscrdy - multipurpose crystal oscillator ready: a ?0-to- 1? transition on the pclksr.xoscrdy bit is detected z xosc32krdy - 32khz crystal oscillator ready: a ?0-to- 1? transition on the pclksr.xosc32krdy bit is detected z osc32krdy - 32khz internal oscillator ready: a ?0-to- 1? transition on the pclksr.osc32krdy bit is detected z osc8mrdy - 8mhz internal oscillator ready: a ?0-to- 1? transition on the pclksr.osc8mrdy bit is detected z dfllrdy - dfll48m ready: a ?0-to-1? transition on the pclksr.dfllrdy bit is detected z dflloob - dfll48m out of boundarie s: a ?0-to-1? transition on the pclksr.dflloob bit is detected z dflllockf - dfll48m fine lock: a ?0-to-1? transiti on on the pclksr.dflllockf bit is detected z dflllockc - dfll48m coarse lock: a ?0-to-1? trans ition on the pclksr.dflllockc bit is detected z dfllrcs - dfll48m reference clock has stopped: a ?0-to-1? transition on the pclksr.dfllrcs bit is detected z bod33rdy - bod33 ready: a ?0-to-1? transiti on on the pclksr.bod33rdy bit is detected z bod33det - bod33 detection: a ?0-to-1? trans ition on the pclksr.bod33det bit is detected z b33srdy - bod33 synchronization ready: a ?0-to-1? transition on the pclksr.b33srdy bit is detected each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear (intflag) register is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set (int enset) register, and disabled by writing a one to the corresponding bit in the interrupt enable clear (intenclr) r egister. an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled, or the sysctr l is reset. see interrupt flag status and clear ( intflag ) register for details on how to clear interrupt flags. all interrupt requests from the peripheral are ored toget her on system level to generate one combined interrupt request to the nvic. refer to ?nested vector interrupt controller? on page 25 for details. the user must read the intflag register to determine which interrupt condition is present. c min vmes vout max ? () temperature voltage ------------------------------------ +
139 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 16.6.11 synchronization due to the multiple clock domains, values in the dfll48m control registers need to be synchronized to other clock domains. the status of this synchronization can be read fr om the power and clocks status register (pclksr). before writing to any of the dfll48m control registers, the user must check that the dfll ready bit (pclksr.dfllrdy) in pclksr is set to one. when this bit is set, the dfll48m can be configured and clk_dfll48m is ready to be used. any write to any of the dfll48m control registers while dfllrdy is zero will be ignored. an interrupt is generated on a zero- to-one transition of dfllrdy if the dfllrdy bit (intense t.dflldy) in the interrupt enable set register is set. in order to read from any of the dfll48m configuration registers, the user must request a read synchronization by writing a one to dfllsync.readreq. the registers can be read only when pclksr.dfllrdy is set. if dfllsync.readreq is not written before a read, a synchronization will be started, and the bus will be halted until the synchronization is complete. reading the dfll48m registers when the dfll48m is disabled will not halt the bus. the prescaler counter used to trigger one-shot brown-out detections also operates asynchronously from the peripheral bus. as a consequence, the prescaler registers require syn chronization when written or read. the synchronization results in a delay from when the initialization of the wr ite or read operation begins until the operation is complete. the write-synchronization is triggered by a write to the bod33 control register. the synchronization ready bit (pclksr.b33srdy) in the pclksr r egister will be cleared when the write-synchronization starts and set when the write-synchronization is complete. when the write-synchr onization is ongoing (pclksr.b33srdyis zero), an attempt to do any of the following will cause the peripheral bus to stall until the synchronization is complete: z writing to the bod33control register z reading the bod33 control register that was written the user can either poll pclksr.b33srdy or use the intenset.b33srdy interrupts to check when the synchronization is complete. it is also possible to perform the next read/write operation and wait, as this next operation will be completed after the ongoing read/write operation is synchronized.
140 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.7 register summary sysctrl register summary offset name bit pos. 0x00 intenclr 7:0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy 0x01 15:8 b33srdy bod33det bod33rdy dfllrcs 0x02 23:16 0x03 31:24 0x04 intenset 7:0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy 0x05 15:8 b33srdy bod33det bod33rdy dfllrcs 0x06 23:16 0x07 31:24 0x08 intflag 7:0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy 0x09 15:8 b33srdy bod33det bod33rdy dfllrcs 0x0a 23:16 0x0b 31:24 0x0c pclksr 7:0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy 0x0d 15:8 b33srdy bod33det bod33rdy dfllrcs 0x0e 23:16 0x0f 31:24 0x10 xosc 7:0 ondemand runstdby xtalen enable 0x11 15:8 startup[3:0] ampgc gain[2:0] 0x12 reserved 0x13 reserved 0x14 xosc32k 7:0 ondemand runstdby aampen en1k en32k xtalen enable 0x15 15:8 wrtlock startup[2:0] 0x16 reserved 0x17 reserved 0x18 osc32k 7:0 ondemand runstdby en1k en32k enable 0x19 15:8 wrtlock startup[2:0] 0x1a 23:16 calib[6:0] 0x1b 31:24 0x1c osculp32k 7:0 wrtlock calib[4:0] 0x1d reserved 0x1e reserved 0x1f reserved 0x20 osc8m 7:0 ondemand runstdby enable 0x21 15:8 presc[1:0] 0x22 23:16 calib[7:0] 0x23 31:24 frange[1:0] calib[11:8] 0x24 dfllctrl 7:0 ondemand llaw stable mode enable 0x25 15:8 qldis ccdis 0x26 reserved 0x27 reserved
141 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x28 dfllval 7:0 fine[7:0] 0x29 15:8 coarse[5:0] fine[9:8] 0x2a 23:16 diff[7:0] 0x2b 31:24 diff[15:8] 0x2c dfllmul 7:0 mul[7:0] 0x2d 15:8 mul[15:8] 0x2e 23:16 fstep[7:0] 0x2f 31:24 cstep[5:0] fstep[9:8] 0x30 dfllsync 7:0 readreq 0x31 reserved 0x32 reserved 0x33 reserved 0x34 bod33 7:0 runstdby action[1:0] hyst enable 0x35 15:8 psel[3:0] cen mode 0x36 23:16 level[5:0] 0x37 31:24 0x38 reserved ... ... 0x3b reserved 0x3c vreg 7:0 runstdby 0x3d 15:8 forceldo 0x3e reserved 0x3f reserved 0x40 vref 7:0 bgouten tsen 0x41 15:8 0x42 23:16 calib[7:0] 0x43 31:24 calib[10:8] 0x45 reserved 0x46 reserved 0x47 reserved 0x51 reserved 0x52 reserved 0x53 reserved sysctrl register su mmary (continued) offset name bit pos.
142 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 130 and the ?pac ? peripheral access controller? on page 28 for details. some registers require synchronization when read and/or written. synchronization is denoted by the synchronized property in each individual register description. refer to ?synchronization? on page 139 for details.
143 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.1 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x00 reset: 0x00000000 property: write-protected z bits 31:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 11 ? b33srdy: bod33 synchr onization ready interrupt enable 0: the bod33 synchronization ready interrupt is disabled. 1: the bod33 synchronization ready interrupt is enabl ed, and an interrupt request will be generated when the bod33 synchronization ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the bod33 synchroni zation ready interrupt enable bit, which disables the bod33 synchronization ready interrupt. z bit 10 ? bod33det: bod33 de tection interrupt enable 0: the bod33 detection interrupt is disabled. bit 31 30292827 26 25 24 access r r r r r r r r reset0 0000 0 0 0 bit 23 22212019 18 17 16 access r r r r r r r r reset0 0000 0 0 0 bit 15 141312 11 10 9 8 b33srdy bod33det bod33rdy dfllrcs access rrrr r/w r/w r/w r/w reset 0 0 0 0 0 0 0 0 bit 7 6 5 4 3 2 1 0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy access r/w r/w r/w r/w r/w r/w r/w r/w reset0 0000 0 0 0
144 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1: the bod33 detection interrupt is enabled, and an interrupt request will be generated when the bod33 detec- tion interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the bod33 detection interrupt enable bit, which disables the bod33 detection interrupt. z bit 9 ? bod33rdy: bod33 ready interrupt enable 0: the bod33 ready interrupt is disabled. 1: the bod33 ready interrupt is enabled, and an interrupt request will be generated when the bod33 ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the bod33 ready interrupt enable bit, which disables the bod33 ready interrupt. z bit 8 ? dfllrcs: dfll reference clock stopped interrupt enable 0: the dfll reference clock stopped interrupt is disabled. 1: the dfll reference clock stopped interrupt is enabled, and an interrupt request will be generated when the dfll reference clock stopped interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the dfll reference cl ock stopped interrupt enable bit, which disables the dfll reference clock stopped interrupt. z bit 7 ? dflllckc: dfll lo ck coarse interrupt enable 0: the dfll lock coarse interrupt is disabled. 1: the dfll lock coarse interrupt is enabled, and an interrupt request will be generated when the dfll lock coarse interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the dfll lock coarse interrupt enable bit, which disables the dfll lock coarse interrupt. z bit 6 ? dflllckf: dfll lock fine interrupt enable 0: the dfll lock fine interrupt is disabled. 1: the dfll lock fine interrupt is enabled, and an interrupt request will be generated when the dfll lock fine interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the dfll lock fine interrupt enable bit, which disables the dfll lock fine interrupt. z bit 5 ? dflloob: dfll out of bounds interrupt enable 0: the dfll out of bounds interrupt is disabled. 1: the dfll out of bounds interrupt is enabled, and an interrupt request will be generated when the dfll out of bounds interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the dfll out of bounds interrupt enable bit, which disables the dfll out of bounds interrupt. z bit 4 ? dfllrdy: dfll ready interrupt enable 0: the dfll ready interrupt is disabled. 1: the dfll ready interrupt is enabled, and an interrupt request will be generated when the dfll ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the dfll ready interrupt enable bit, which disables the dfll ready interrupt.
145 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 3 ? osc8mrdy: osc8m ready interrupt enable 0: the osc8m ready interrupt is disabled. 1: the osc8m ready interrupt is enabled, and an interrupt request will be generated when the osc8m ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the osc8m ready interrupt enable bit, which disables the osc8m ready interrupt. z bit 2 ? osc32krdy: osc32k ready interrupt enable 0: the osc32k ready interrupt is disabled. 1: the osc32k ready interrupt is enabled, and an interrupt request will be generated when the osc32k ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the osc32k ready interrupt enable bit, which disables the osc32k ready interrupt. z bit 1 ? xosc32krdy: xosc32k ready interrupt enable 0: the xosc32k ready interrupt is disabled. 1: the xosc32k ready interrupt is enabled, and an interrupt request will be generated when the xosc32k ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the xosc32k ready interrupt enable bit, which disables the xosc32k ready interrupt. z bit 0 ? xoscrdy: xosc ready interrupt enable 0: the xosc ready interrupt is disabled. 1: the xosc ready interrupt is enabled, and an interrupt request will be generated when the xosc ready inter- rupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the xosc ready interrupt enable bit, which disables the xosc ready interrupt.
146 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.2 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x04 reset: 0x00000000 property: write-protected z bits 31:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 11 ? b33srdy: bod33 synchr onization ready interrupt enable 0: the bod33 synchronization ready interrupt is disabled. 1: the bod33 synchronization ready interrupt is enabl ed, and an interrupt request will be generated when the bod33 synchronization ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the bod33 synchronization ready interrupt enable bit, which enables the bod33 synchronization ready interrupt. z bit 10 ? bod33det: bod33 de tection interrupt enable 0: the bod33 detection interrupt is disabled. bit31302928 27 26 25 24 access r r r r r r r r reset0000 0 0 0 0 bit23222120 19 18 17 16 access r r r r r r r r reset0000 0 0 0 0 bit15141312 11 10 9 8 b33srdy bod33det bod33rdy dfllrcs access rrrr r/w r/w r/w r/w reset 0 0 0 0 0 0 0 0 bit 7 6 5 4 3 2 1 0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy access r/w r/w r/w r/w r/w r/w r/w r/w reset0000 0 0 0 0
147 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1: the bod33 detection interrupt is enabled, and an interrupt request will be generated when the bod33 detec- tion interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the bod33 detection interrupt enable bit, which enables the bod33 detection interrupt. z bit 9 ? bod33rdy: bod33 ready interrupt enable 0: the bod33 ready interrupt is disabled. 1: the bod33 ready interrupt is enabled, and an interrupt request will be generated when the bod33 ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the bod33 ready interrupt enable bit, which enables the bod33 ready interrupt. z bit 8 ? dfllrcs: dfll reference clock stopped interrupt enable 0: the dfll reference clock stopped interrupt is disabled. 1: the dfll reference clock stopped interrupt is enabled, and an interrupt request will be generated when the dfll reference clock stopped interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the dfll reference clock stopped interrupt enable bit, which enables the dfll reference clock stopped interrupt. z bit 7 ? dflllckc: dfll lo ck coarse interrupt enable 0: the dfll lock coarse interrupt is disabled. 1: the dfll lock coarse interrupt is enabled, and an interrupt request will be generated when the dfll lock coarse interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the dfll lock coarse interrupt enable bit, which enables the dfll lock coarse interrupt. z bit 6 ? dflllckf: dfll lock fine interrupt enable 0: the dfll lock fine interrupt is disabled. 1: the dfll lock fine interrupt is enabled, and an interrupt request will be generated when the dfll lock fine interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the dfll lock fine interrupt disable/enable bit, disable the dfll lock fine inter- rupt and set the corresponding interrupt request. z bit 5 ? dflloob: dfll out of bounds interrupt enable 0: the dfll out of bounds interrupt is disabled. 1: the dfll out of bounds interrupt is enabled, and an interrupt request will be generated when the dfll out of bounds interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the dfll out of bounds interrupt enable bit, which enables the dfll out of bounds interrupt. z bit 4 ? dfllrdy: dfll ready interrupt enable 0: the dfll ready interrupt is disabled. 1: the dfll ready interrupt is enabled, and an interrupt request will be generated when the dfll ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the dfll ready interrupt enable bit, which enables the dfll ready interrupt and set the corresponding interrupt request.
148 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 3 ? osc8mrdy: osc8m ready interrupt enable 0: the osc8m ready interrupt is disabled. 1: the osc8m ready interrupt is enabled, and an interrupt request will be generated when the osc8m ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the osc8m ready interrupt enable bit, which enables the osc8m ready interrupt. z bit 2 ? osc32krdy: osc32k ready interrupt enable 0: the osc32k ready interrupt is disabled. 1: the osc32k ready interrupt is enabled, and an interrupt request will be generated when the osc32k ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the osc32k ready interrupt enable bit, which enables the osc32k ready interrupt. z bit 1 ? xosc32krdy: xosc32k ready interrupt enable 0: the xosc32k ready interrupt is disabled. 1: the xosc32k ready interrupt is enabled, and an interrupt request will be generated when the xosc32k ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the xosc32k ready interrupt enable bit, which enables the xosc32k ready interrupt. z bit 0 ? xoscrdy: xosc ready interrupt enable 0: the xosc ready interrupt is disabled. 1: the xosc ready interrupt is enabled, and an interrupt request will be generated when the xosc ready inter- rupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will set the xosc ready interrupt enable bit, which enables the xosc ready interrupt.
149 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.3 interrupt flag status and clear name: intflag offset: 0x08 reset: 0x00000000 property: - note: depending on the fuse settings, various bits of the intflag re gister can be set to one at startup. therefore the user shou ld clear those bits before using the corresponding interrupts. z bits 31:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 11 ? b33srdy: bod33 synchronization ready this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the bod 33 synchronization ready bit in the status register (pclksr.b33srdy) and will generate an interr upt request if intenset.b33srdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the bod33 synchronization ready interrupt flag z bit 10 ? bod33det: bod33 detection this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the bod33 detection bit in the status register (pclksr.bod33det) and will generate an interrupt request if intenset.bod33det is one. bit313029282726 2524 access r r r r r r r r reset000000 00 bit232221201918 1716 access r r r r r r r r reset000000 00 bit151413121110 9 8 b33srdy bod33det bod33rdy dfllrcs access rrrr r/w r/w r/w r/w reset 0 0 0 0 0 0 0 0 bit 7 6 5 4 3 2 1 0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy access r/w r/w r/w r/w r/w r/w r/w r/w reset000000 00
150 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a zero to this bit has no effect. writing a one to this bit clears the bod33 detection interrupt flag. z bit 9 ? bod33rdy: bod33 ready this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the bod33 ready bit in the status register (pclksr.bod33rdy) and will generate an interrupt request if intenset.bod33rdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the bod33 ready interrupt flag. z bit 8 ? dfllrcs: dfll reference clock stopped this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the dfll reference clock stopped bit in the status register (pclksr.dfllrcs) and will generate an interrupt request if intenset.dfllrcs is one. writing a zero to this bit has no effect. writing a one to this bit clears the dfll reference clock stopped interrupt flag. z bit 7 ? dflllckc: dfll lock coarse this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the dfll lock coarse bit in the status register (pclksr.dflll- ckc) and will generate an interrupt request if intenset.dflllckc is one. writing a zero to this bit has no effect. writing a one to this bit clears the dfll lock coarse interrupt flag. z bit 6 ? dflllckf: dfll lock fine this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the dfll lock fine bit in the status register (pclksr.dflllckf) and will generate an interrupt request if intenset.dflllckf is one. writing a zero to this bit has no effect. writing a one to this bit clears the dfll lock fine interrupt flag. z bit 5 ? dflloob: dfll out of bounds this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the dfll ou t of bounds bit in the status register (pclksr.dfl- loob) and will generate an interrupt request if intenset.dflloob is one. writing a zero to this bit has no effect. writing a one to this bit clears the dfll out of bounds interrupt flag. z bit 4 ? dfllrdy: dfll ready this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the dfll ready bit in the status register (pclksr.dfllrdy) and will generate an interrupt reques t if intenset.dfllrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the dfll ready interrupt flag. z bit 3 ? osc8mrdy: osc8m ready this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the osc8m ready bit in the status register (pclksr.osc8mrdy) and will generate an interrupt request if intenset.osc8mrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the osc8m ready interrupt flag.
151 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 2 ? osc32krdy: osc32k ready this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the osc32k ready bit in the status register (pclksr.osc32krdy) and will generate an interrupt request if intenset.osc32krdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the osc32k ready interrupt flag. z bit 1 ? xosc32krdy: xosc32k ready this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the xosc32k ready bit in the status register (pclksr.xosc32krdy) and will generate an inte rrupt request if intenset.xosc32krdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the xosc32k ready interrupt flag. z bit 0 ? xoscrdy: xosc ready this flag is cleared by writing a one to it. this flag is set on a zero-to-one transition of the xosc ready bit in the status register (pclksr.xoscrdy) and will generate an interrupt reques t if intenset.xoscrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the xosc ready interrupt flag.
152 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.4 power and clocks status name: pclksr offset: 0x0c reset: 0x00000000 property: - z bits 31:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 11 ? b33srdy: bod33 synchronization ready 0: bod33 synchronization is complete. 1: bod33 synchronization is ongoing. z bit 10 ? bod33det: bod33 detection 0: no bod33 detection. 1: bod33 has detected that the i/o power supply is going below the bod33 reference value. z bit 9 ? bod33rdy: bod33 ready 0: bod33 is not ready. 1: bod33 is ready. z bit 8 ? dfllrcs: dfll reference clock stopped 0: dfll reference clock is running. 1: dfll reference clock has stopped. bit313029282726 25 24 access r r r r r r r r reset 0 0 0 0 0 0 0 0 bit232221201918 17 16 access r r r r r r r r reset 0 0 0 0 0 0 0 0 bit1514131211 10 9 8 b33srdy bod33det bod33rdy dfllrcs access rrrr r r r r reset 0 0 0 0 0 0 0 0 bit 7 6 5 4 3 2 1 0 dflllckc dflllckf dflloob dfllrdy osc8mrdy osc32krdy xosc32krdy xoscrdy access r r r r r r r r reset 0 0 0 0 0 0 0 0
153 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 7 ? dflllckc: dfll lock coarse 0: no dfll coarse lock detected. 1: dfll coarse lock detected. z bit 6 ? dflllckf: dfll lock fine 0: no dfll fine lock detected. 1: dfll fine lock detected. z bit 5 ? dflloob: dfll out of bounds 0: no dfll out of bounds detected. 1: dfll out of bounds detected. z bit 4 ? dfllrdy: dfll ready 0: the synchronization is ongoing. 1: the synchronization is complete. this bit is cleared when the synchronization of registers between clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bit 3 ? osc8mrdy: osc8m ready 0: osc8m is not ready. 1: osc8m is stable and ready to be used as a clock source. z bit 2 ? osc32krdy: osc32k ready 0: osc32k is not ready. 1: osc32k is stable and ready to be used as a clock source. z bit 1 ? xosc32krdy: xosc32k ready 0: xosc32k is not ready. 1: xosc32k is stable and ready to be used as a clock source. z bit 0 ? xoscrdy: xosc ready 0: xosc is not ready. 1: xosc is stable and ready to be used as a clock source.
154 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.5 external multipurpose crystal oscillator (xosc) control name: xosc offset: 0x10 reset: 0x0080 property: write-protected z bits 15:12 ? startup[3:0]: start-up time these bits select start-up time for the oscillator according to table 16-3 . the osculp32k oscillator is used to clock the start-up counter. bit151413121110 9 8 startup[3:0] ampgc gain[2:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 ondemand runstdby xtalen enable access r/w r/w r r r r/w r/w r reset10000000 table 16-3. start-uptime for external multipurpose crystal oscillator startup[3:0] number of osculp32k clock cycles (1) number of xosc clock cycles (2) approximate equivalent time (osculp=32.768khz) (3) 0x0 1 3 31s 0x1 2 3 61s 0x2 4 3 122s 0x3 8 3 244s 0x4 16 3 488s 0x5 32 3 977s
155 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 notes: 1. number of cycles for the start-up counter. 2. number of cycles for the synchronizati on delay, before pclksr.xoscrdy is set. 3. actual start-up time is n osculp32k cycles + 3 xosc cycles, but given the time n eglects the 3 xosc cycles. z bit 11 ? ampgc: automatic amplitude gain control 0: the automatic amplitude gain control is disabled. 1: the automatic amplitude gain control is enabled. amplitude gain will be automatically adjusted during crystal oscillator operation. z bits 10:8 ? gain[2:0]: oscillator gain these bits select the gain for the oscillator, given in table table 16-4 . the listed maximum frequencies are recom- mendations, and might vary based on capacitive load and crystal characteristics. setting this bit group has no effect when the automatic amplitude gain control is active. z bit 7 ? ondemand: on demand control the on demand operation mode allows an oscillator to be enabled or disabled, depending on peripheral clock requests. in on demand operation mode, i.e., if the xosc.ondemand bit has been previously written to one, the oscillator will be running only when requested by a peripheral. if t here is no peripheral requesting the oscillator?s clock source, the oscillator will be in a disabled state. if on demand is disabled, the oscillator will always be running when enabled. in standby sleep mode, the on demand operation is still active if the xosc.runstdby bit is one. if xosc.runstdby is zero, the oscillator is disabled. 0x6 64 3 1953s 0x7 128 3 3906s 0x8 256 3 7813s 0x9 512 3 15625s 0xa 1024 3 31250s 0xb 2048 3 62500s 0xc 4096 3 125000s 0xd 8192 3 250000s 0xe 16384 3 500000s 0xf 32768 3 1000000s table 16-3. start-uptime for external multipurpose crystal oscillator table 16-4. external multipurpose crystal oscillator gain settings gain[2:0] recommended max frequency 0x0 2mhz 0x1 4mhz 0x2 8mhz 0x3 16mhz 0x4 30mhz 0x5-0x7 reserved
156 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0: the oscillator is always on, if enabled. 1: the oscillator is enabled when a peripheral is requesting the oscillator to be used as a clock source. the oscilla- tor is disabled if no peripheral is requesting the clock source. z bit 6 ? runstdby: run in standby this bit controls how the xosc behaves during standby sleep mode: 0: the oscillator is disabled in standby sleep mode. 1: the oscillator is not stopped in standby sleep mode. if xosc.ondemand is one, the clock source will be run- ning when a peripheral is requesting the clock. if xosc.ondemand is zero, the clock source will always be running in standby sleep mode. z bits 5:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? xtalen: crystal oscillator enable this bit controls the connections between the i/o pads and the external clock or crystal oscillator: 0: external clock connected on xin. xout can be used as general-purpose i/o. 1: crystal connected to xin/xout. z bit 1 ? enable: oscillator enable 0: the oscillator is disabled. 1: the oscillator is enabled. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read.
157 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.6 32khz external crystal oscillator (xosc32k) control name: xosc32k offset: 0x14 reset: 0x0080 property: write-protected z bits 15:13 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 12 ? wrtlock: write lock this bit locks the xosc32k register for futur writes to fix the xosc32k configuration. 0: the xosc32k configuration is not locked. 1: the xosc32k configuration is locked. z bit 11 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 10:8 ? startup[2:0]: oscillator start-up time these bits select the start-up time for the oscillator according to table 16-5 the osculp32k oscillator is used to clock the start-up counter. bit151413121110 9 8 wrtlock startup[2:0] access r r r r/w r r/w r/w r/w reset00000000 bit76543210 ondemand runstdby aampen en1k en32k xtalen enable access r/w r/w r/w r/w r/w r/w r/w r reset10000000 table 16-5. start-up time for 32kh z external cryst al oscillator startup[2:0] number of osculp32k clock cycles (1) number of xosc32k clock cycles (2) approximate equivalent time (osculp = 32.768khz) (3) 0x0 1 3 122s 0x1 32 3 1068s 0x2 2048 3 62592s 0x3 4096 3 125092s 0x4 16384 3 500092s 0x5 32768 3 1000092s 0x6 65536 3 2000092s 0x7 131072 3 4000092s
158 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 notes: 1. number of cycles for the start-up counter. 2. number of cycles for the synchronization delay, before pclksr.xosc32krdy is set. 3. start-up time is n osculp32k cycles + 3 xosc32k cycles. z bit 7 ? ondemand: on demand control the on demand operation mode allows an oscillator to be enabled or disabled depending on peripheral clock requests. in on demand operation mode, i.e., if the ondemand bit has been previously written to one, the oscillator will only be running when requested by a peripheral. if there is no peripheral requesting the oscillator?s clock source, the oscillator will be in a disabled state. if on demand is disabled the oscillator will always be running when enabled. in standby sleep mode, the on demand operation is still active if the xosc32k.runstdby bit is one. if xosc32k.runstdby is zero, t he oscillator is disabled. 0: the oscillator is always on, if enabled. 1: the oscillator is enabled when a peripheral is requesting the oscillator to be used as a clock source. the oscilla- tor is disabled if no peripheral is requesting the clock source. z bit 6 ? runstdby: run in standby this bit controls how the xosc32k behaves during standby sleep mode: 0: the oscillator is disabled in standby sleep mode. 1: the oscillator is not stopped in standby sleep mode. if xosc32k.ondemand is one, the clock source will be running when a peripheral is requesti ng the clock. if xosc32k.ondemand is zero, the clock source will always be running in standby sleep mode. z bit 5 ? aampen: automatic amplitude control enable 0: the automatic amplitude control for the crystal oscillator is disabled. 1: the automatic amplitude control for the crystal oscillator is enabled. z bit 4 ? en1k: 1khz output enable 0: the 1khz output is disabled. 1: the 1khz output is enabled. z bit 3 ? en32k: 32khz output enable 0: the 32khz output is disabled. 1: the 32khz output is enabled. z bit 2 ? xtalen: crystal oscillator enable this bit controls the connections between the i/o pads and the external clock or crystal oscillator: 0: external clock connected on xin32. xout32 can be used as general-purpose i/o. 1: crystal connected to xin32/xout32. z bit 1 ? enable: oscillator enable 0: the oscillator is disabled. 1: the oscillator is enabled. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read.
159 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.7 32khz internal osc illator (osc32k) control name: osc32k offset: 0x18 reset: 0x00000080 property: write-protected z bits 31:23 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 22:16 ? calib[6:0]: oscillator calibration these bits control the oscillator calibration. this value must be written by the user. factory calibration values can be loaded from the non-volatile memory. refer to ?nvm software calibration area mapping? on page 23 . z bits 15:13 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 12 ? wrtlock: write lock this bit locks the osc32k register for futu r writes to fix the osc32k configuration. 0: the osc32k configuration is not locked. 1: the osc32k configuration is locked. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 calib[6:0] accessr r/wr/wr/wr/wr/wr/wr/w reset00000000 bit151413121110 9 8 wrtlock startup[2:0] access r r r r/w r r/w r/w r/w reset00000000 bit76543210 ondemand runstdby en1k en32k enable access r/w r/w r r r/w r/w r/w r reset10000000
160 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 11 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 10:8 ? startup[2:0]: oscillator start-up time these bits select start-up time for the oscillator according to table 16-6 . the osculp32k oscillator is used as input clock to the startup counter. notes: 1. number of cycles for the start-up counter. 2. number of cycles for the synchronization delay, before pclksr.osc32krdy is set. 3. start-up time is n osc32k cycles + 2 osc32k cycles. z bit 7 ? ondemand: on demand control the on demand operation mode allows an oscillator to be enabled or disabled depending on peripheral clock requests. in on demand operation mode, i.e., if the ondemand bit has been previously written to one, the oscillator will only be running when requested by a peripheral. if there is no peripheral requesting the oscillator?s clock source, the oscillator will be in a disabled state. if on demand is disabled the oscillator will always be running when enabled. in standby sleep mode, the on demand operation is still active if the osc32k.runstdby bit is one. if osc32k.runstdby is zero, the oscillator is disabled. 0: the oscillator is always on, if enabled. 1: the oscillator is enabled when a peripheral is requesting the oscillator to be used as a clock source. the oscilla- tor is disabled if no peripheral is requesting the clock source. z bit 6 ? runstdby: run in standby this bit controls how the osc32k behaves during standby sleep mode: 0: the oscillator is disabled in standby sleep mode. 1: the oscillator is not stopped in standby sleep mode. if osc32k.ondemand is one, the clock source will be running when a peripheral is requesting the clock. if osc3 2k.ondemand is zero, the clock source will always be running in standby sleep mode. z bits 5:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. table 16-6. start-up time for 32khz internal oscillator startup[2:0] number of osc32k clock cycles (1) number of osc32k clock cycles (2) approximate equivalent time (osculp= 32.768khz) (3) 0x0 1 2 92s 0x1 2 2 122s 0x2 4 2 183s 0x3 8 2 305s 0x4 16 2 549s 0x5 32 2 1038s 0x6 64 2 2014s 0x7 128 2 3967s
161 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 3 ? en1k: 1khz output enable 0: the 1khz output is disabled. 1: the 1khz output is enabled. z bit 2 ? en32k: 32khz output enable 0: the 32khz output is disabled. 1: the 32khz output is enabled. z bit 1 ? enable: oscillator enable 0: the oscillator is disabled. 1: the oscillator is enabled. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read.
162 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.8 32khz ultra low power internal oscillator (osculp32k) control name: osculp32k offset: 0x1c reset: 0xxx property: write-protected z bit 7 ? wrtlock: write lock this bit locks the osculp32k register for future writes to fix the osculp32k configuration. 0: the osculp32k configuration is not locked. 1: the osculp32k configuration is locked. z bits 6:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:0 ? calib[4:0]: oscillator calibration these bits control the oscillator calibration. these bits are loaded from flash calibration at startup. bit76543210 wrtlock calib[4:0] access r/w r r r/w r/w r/w r/w r/w reset0 0 0xxxxx
163 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.9 8mhz internal oscillator (osc8m) control name: osc8m offset: 0x20 reset: 0xxxxx0382 property: write-protected z bits 31:30 ? frange[1:0]: o scillator frequency range these bits control the oscillator frequency range according to table 16-7 .these bits are loaded from flash cali- bration at startup. z bits 29:28 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit3130292827262524 frange[1:0] calib[11:8] accessr/wr/w r r r/wr/wr/wr/w resetxx0 0xxxx bit2322212019181716 calib[7:0] accessr/wr/wr/wr/wr/wr/wr/wr/w resetxxxxxxxx bit151413121110 9 8 presc[1:0] accessrrrrrrr/wr/w reset00000011 bit76543210 ondemand runstdby enable access r/w r/w r r r r r/w r reset10000010 table 16-7. oscillator frequency range frange[1:0] description 0x0 4 to 6mhz 0x1 6 to 8mhz 0x2 8 to 11mhz 0x3 11 to 15mhz
164 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 27:16 ? calib[11:0]: oscillator calibration these bits control the oscillator calibrati on. the calibration field is split in two: calib[11:6] is for temperature calibration calib[5:0] is for overall process calibration these bits are loaded from flash calibration at startup. z bits 15:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 9:8 ? presc[1:0]: oscillator prescaler these bits select the oscillator prescaler factor setting according to the table 16-8 . z bit 7 ? ondemand: on demand control the on demand operation mode allows an oscillator to be enabled or disabled depending on peripheral clock requests. in on demand operation mode, i.e., if the ondemand bit has been previously written to one, the oscillator will only be running when requested by a peripheral. if there is no peripheral requesting the oscillator?s clock source, the oscillator will be in a disabled state. if on demand is disabled the oscillator will always be running when enabled. in standby sleep mode, the on demand operation is still active if the osc8m.runstdby bit is one. if osc8m.runstdby is zero, the oscillator is disabled. 0: the oscillator is always on, if enabled. 1: the oscillator is enabled when a peripheral is requesting the oscillator to be used as a clock source. the oscilla- tor is disabled if no peripheral is requesting the clock source. z bit 6 ? runstdby: run in standby this bit controls how the osc8m behaves during standby sleep mode: 0: the oscillator is disabled in standby sleep mode. 1: the oscillator is not stopped in standby sleep mode. if osc8m.ondemand is one, the clock source will be run- ning when a peripheral is requesting the clock. if osc8 m.ondemand is zero, the clock source will always be running in standby sleep mode. z bits 5:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? enable: oscillator enable 0: the oscillator is disabled or being enabled. 1: the oscillator is enabled or being disabled. the user must ensure that the osc8m is fully disabled before enabling it, and that the osc8m is fully enabled before disabling it by reading osc8m.enable. table 16-8. oscill ator prescaler presc[1:0] description 0x0 1 0x1 2 0x2 4 0x3 8
165 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read.
166 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.10 dfll48m control name: dfllctrl offset: 0x24 reset: 0x0080 property: write-protected, write-synchronized z bits 15:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 9 ? qldis: quick lock disable 0: quick lock is enabled. 1: quick lock is disabled. z bit 8 ? ccdis: chill cycle disable 0: chill cycle is enabled. 1: chill cycle is disabled. z bit 7 ? ondemand: on demand control the on demand operation mode allows an oscillator to be enabled or disabled depending on peripheral clock requests. in on demand operation mode, i.e., if the ondemand bit has been previously written to one, the oscillator will only be running when requested by a peripheral. if there is no peripheral requesting the oscillator?s clock source, the oscillator will be in a disabled state. if on demand is disabled the oscillator will always be running when enabled. 0: the oscillator is always on, if enabled. 1: the oscillator is enabled when a peripheral is requesting the oscillator to be used as a clock source. the oscilla- tor is disabled if no peripheral is requesting the clock source. z bit 6 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 5 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit151413121110 9 8 qldis ccdis accessrrrrrrr/wr/w reset00000000 bit76543210 ondemand llaw stable mode enable access r/w r r r/w r/w r/w r/w r reset10000000
167 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 4 ? llaw: lose lock after wake 0: locks will not be lost after waking up from sleep modes if the dfll clock has been stopped. 1: locks will be lost after waking up from sleep modes if the dfll clock has been stopped. z bit 3 ? stable: stable dfll frequency 0: fine calibration tracks changes in output frequency. 1: fine calibration register value will be fixed after a fine lock. z bit 2 ? mode: operating mode selection 0: the dfll operates in open-loop operation. 1: the dfll operates in closed-loop operation. z bit 1 ? enable: dfll enable 0: the dfll oscillator is disabled. 1: the dfll oscillator is enabled. due to synchronization, there is delay from updating the register until the peripheral is enabled/disabled. the value written to dfllctrl.enable will read back immediately after written. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read.
168 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.11 dfll48m value name: dfllval offset: 0x28 reset: 0x00000000 property: write-protected, read-synchronized z bits 31:16 ? diff: multiplication ratio difference in closed-loop mode (dfllctrl.mode is written to one), th is bit group indicates the difference between the ideal number of dfll cycles and the counted number of cycles. this value is not updated in open-loop mode, and should be considered invalid in that case. z bits 15:10 ? coarse: coarse value set the value of the coarse calibration register. in closed-loop mode, this field is read-only. z bits 9:0 ? fine: fine value set the value of the fine calibration register. in closed-loop mode, this field is read-only. bit3130292827262524 diff[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit2322212019181716 diff[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 coarse[5:0] fine[9:8] access r r r r/w r/w r/w r/w r/w reset00000000 bit76543210 fine[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
169 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.12 dfll48m multiplier name: dfllmul offset: 0x2c reset: 0x00000000 property: write-protected z bits 31:26 ? cstep: coarse maximum step this bit group indicates the maximum step size allow ed during coarse adjustment in closed-loop mode. when adjusting to a new frequency, the expected output frequency overshoot depends on this step size. z bits 25:16 ? fstep: fine maximum step this bit group indicates the maximum step size allow ed during fine adjustment in closed-loop mode. when adjust- ing to a new frequency, the expected output frequency overshoot depends on this step size. z bits 15:0 ? mul: dfll multiply factor this field determines the ratio of the clk_dfll output frequency to the clk_dfll_ref input frequency. writing to the mul bits will cause locks to be lost and t he fine calibration value to be reset to its midpoint. bit3130292827262524 cstep[5:0] fstep[9:8] access r r r r/w r/w r/w r/w r/w reset00000000 bit2322212019181716 fstep[7:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit151413121110 9 8 mul[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 mul[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
170 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.13 dfll48m synchronization name: dfllsync offset: 0x30 reset: 0x00 property: write-protected z bit 7 ? readreq: read request to be able to read the current value of dfllval in cl osed-loop mode, this bit should be written to one. the updated value is available in dfllval when pclksr.dfllrdy is set. z bits 6:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit76543210 readreq accesswrrrrrrr reset00000000
171 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.14 3.3v brown-out de tector (bod33) control name: bod33 offset: 0x34 reset: 0x00xx00xx property: synchronized, write-protected z bits 31:22 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 21:16 ? level[5:0] : bod33 threshold level this field sets the triggering voltage threshold for the bod33. see the ?electrical characteristics? on page 563 for actual voltage levels. note that any change to the le vel field of the bod33 register should be done when the bod33 is disabled in order to avoid spurious resets or interrupts. these bits are loaded from flash user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bits 15:12 ? psel[3:0]: prescaler select selects the prescaler divide-by output for the bod33 sampling mode, as given in table 16-9 . the input clock comes from the osculp32k 1khz output. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 level[5:0] access r r r/w r/w r/w r/w r/w r/w reset0 0xxxxxx bit151413121110 9 8 psel[3:0] cen mode access r/w r/w r/w r/w r r r/w r/w reset00000000 bit76543210 runstdby action[1:0] hyst enable access r r/w r r/w r/w r/w r/w r reset000xxxx0
172 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 11:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 9 ? cen: clock enable 0: the bod33 sampling clock is either disabled and stopped, or enabled but not yet stable. 1: the bod33 sampling clock is either enabled and stable, or disabled but not yet stopped. writing a zero to this bit will stop the bod33 sampling clock. writing a one to this bit will start the bod33 sampling clock. z bit 8 ? mode: operation mode 0: the bod33 operates in continuous mode. 1: the bod33 operates in sampling mode. z bit 7 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 6 ? runstdby: run in standby 0: the bod33 is disabled in standby sleep mode. 1: the bod33 is enabled in standby sleep mode. z bit 5 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. table 16-9. bod33 prescaler select psel[3:0] name description 0x0 div2 divide clock by 2 0x1 div4 divide clock by 4 0x2 div8 divide clock by 8 0x3 div16 divide clock by 16 0x4 div32 divide clock by 32 0x5 div64 divide clock by 64 0x6 div128 divide clock by 128 0x7 div256 divide clock by 256 0x8 div512 divide clock by 512 0x9 div1k divide clock by 1024 0xa div2k divide clock by 2048 0xb div4k divide clock by 4096 0xc div8k divide clock by 8192 0xd div16k divide clock by 16384 0xe div32k divide clock by 32768 0xf div64k divide clock by 65536
173 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 4:3 ? action: bod33 action these bits are used to select the bod33 action when the supply voltage crosses below the bod33 threshold, as shown in table 16-10 . these bits are loaded from flash user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bit 2 ? hyst: hysteresis this bit indicates whether hysteresis is enabled for the bod33 threshold voltage: 0: no hysteresis. 1: hysteresis enabled. this bit is loaded from flash user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bit 1 ? enable: enable 0: bod33 is disabled. 1: bod33 is enabled. this bit is loaded from flash user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. table 16-10. bod33 action action[1:0] name description 0x0 none no action 0x1 reset the bod33 generates a reset 0x2 interrupt the bod33 generates an interrupt 0x3 - reserved
174 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.15 voltage regulator system (vreg) control name: vreg offset: 0x3c reset: 0x0x02 property: write protected z bits 15:14 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 13 ? forceldo: force high drive 0: the voltage regulator is in low power and low drive configuration in standby sleep mode. 1: the voltage regulator is in low power and high drive configuration in standby sleep mode. z bits 12:7 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 6 ? runstdby: run in standby 0: the voltage regulator is in low power configuration in standby sleep mode. 1: the voltage regulator is in normal configuration in standby sleep mode. z bits 5:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit151413121110 9 8 forceldo accessrrr/wrrrrr reset00000000 bit76543210 runstdby accessrr/wrrrrrr reset00000010
175 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 16.8.16 voltage references system (vref) control name: vref offset: 0x40 reset: 0x0xxx0000 property: write-protected z bits 31:27 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 26:16 ? calib[10:0]: bandgap voltage generator calibration these bits are used to calibrate the output level of the bandgap voltage reference. these bits are loaded from flash calibration row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bits 15:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? bgouten: bandgap output enable 0: the bandgap output is not available as an adc input channel. 1: the bandgap output is routed to an adc input channel. z bit 1 ? tsen: temper ature sensor enable 0: temperature sensor is disabled. bit3130292827262524 calib[10:8] accessrrrrrr/wr/wr/w reset00000xxx bit2322212019181716 calib[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w resetxxxxxxxx bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 bgouten tsen accessrrrrrr/wr/wr reset00000000
176 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1: temperature sensor is enabled and routed to an adc input channel. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read.
177 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17. wdt ? watchdog timer 17.1 overview the watchdog timer (wdt) is a system function for monitoring correct program operation. it makes it possible to recover from error situations such as runaway or deadlocked code. the wdt is configured to a predefined time-out period, and is constantly running when enabled. if the wdt is not cleared within the time-out period, it will issue a system reset. an early-warning interrupt is available to indi cate an upcoming watchdog time-out condition. the window mode makes it possible to define a time slot (or window) inside the total time-out period during which the wdt must be cleared. if the wdt is cleared outside this window , either too early or too late, a system reset will be issued. compared to the normal mode, this can also catch situations where a code error causes the wdt to be cleared frequently. when enabled, the wdt will run in active mode and all sleep modes. it is asynchronous and runs from a cpu- independent clock source.the wdt will continue operation and issue a system reset or interrupt even if the main clocks fail. 17.2 features z issues a system reset if the watchdog timer is not cleared before its time-out period z early warning interrupt generation z asynchronous operation from dedicated oscillator z two types of operation: z normal mode z window mode z selectable time-out periods, from 8 cycles to 16,000 cycles in normal mode or 16 cycles to 32,000 cycles in window mode z always-on capability 17.3 block diagram figure 17-1. wdt block diagram gclk_wdt count reset per/window/ewoffset 0 clear 0xa5 early warning interrupt
178 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.4 signal description not applicable. 17.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 17.5.1 i/o lines not applicable. 17.5.2 power management the wdt can continue to operate in any sleep mode where the selected source clock is running. the wdt interrupts can be used to wake up the device from sleep modes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 17.5.3 clocks the wdt bus clock (clk_wdt_apb) is enabled by defau lt, and can be enabled and disabled in the power manager. refer to ?pm ? power manager? on page 101 for details. a generic clock (gclk_wdt) is required to clock the wdt. this clock must be configured and enabled in the generic clock controller before using the wdt. refer to ?gclk ? generic clock controller? on page 79 for details. this generic clock is asynchronous to the user interface cl ock (clk_wdt_apb). due to this asynchronicity, accessing certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 183 for further details. gclk_wdt is intended to be sourced from the clock of the in ternal ultra-low-power (ulp) oscillator. due to the ultra- low-power design, the oscillator is not very accurate, and so the exact time-out period may vary from device to device. this variation must be kept in mind when designing software t hat uses the wdt to ensure that the time-out periods used are valid for all devices. for more information on ulp oscillator accuracy, consult the ?ultra low power internal 32khz rc oscillator (osculp32k) characteristics? on page 589 . gclk_wdt can also be clocked from other sources if a more accurate clock is needed, but at the cost of higher power consumption. 17.5.4 dma not applicable. 17.5.5 interrupts the interrupt request line is connected to the interrupt c ontroller. using the wdt interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 17.5.6 events not applicable. 17.5.7 debug operation when the cpu is halted in debug mode, the wdt will halt normal operation. if the wdt is configured in a way that requires it to be periodically serviced by the cpu through inte rrupts or similar, improper operation or data loss may result during debugging. the wdt can be forced to halt operation during debugging.
179 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.5.8 register access protection all registers with write-access are optionally write-protect ed by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register (intflag - refer to intflag ) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all wr ite-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 17.5.9 analog connections not applicable. 17.6 functional description 17.6.1 principle of operation the watchdog timer (wdt) is a system for monitoring correct program operation, making it possible to recover from error situations such as runaway code by issuing a reset. when enabled, the wdt is a constantly running timer that is configured to a predefined time-out period. before the e nd of the time-out period, the wdt should be reconfigured. the wdt has two modes of operation, normal and window. addi tionally, the user can enable early warning interrupt generation in each of the modes. the description for each of the basic modes is given below. the settings in the control register (ctrl - refer to ctrl ) and the interrupt enable register (intenclr/set - refer to intenclr ) determine the mode of operation, as illustrated in table 17-1 . 17.6.2 basic operation 17.6.2.1 initialization the following registers are enable-protected: z control register (ctrl - refer to ctrl ), except the enable bit (ctrl.enable) z configuration register (config - refer to config ) z early warning interrupt control register (ewctrl - refer to ewctrl ) any writes to these bits or registers when the wdt is enabled or is being enabled (ctrl.enable is one) will be discarded. writes to these registers while the wdt is being disabled will be completed after the disabling is complete. enable-protection is denoted by the enable-protected property in the register description. initialization of the wdt can be done only while the wdt is disabled. the wdt is configured by defining the required time-out period bits in the configuration register (c onfig.per). if window-mode operation is required, the window table 17-1. wdt operating modes enable wen interrupt enable mode 0 x x stopped 1 0 0 normal 1 0 1 normal with early warning interrupt 1 1 0 window 1 1 1 window with early warning interrupt
180 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 enable bit in the control register (ctrl.wen) must be writ ten to one and the window period bits in the configuration register (config.window) must be defined. 17.6.2.2 configurable reset values on a power-on reset, some registers will be loaded with initial values from the nvm user row. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. this encompasses the following bits and bit groups: z enable bit in the control register (ctrl.enable) z always-on bit in the contro l register (ctrl.alwayson) z watchdog timer windows mode enable bit in the control register (ctrl.wen) z watchdog timer windows mode time-out period bits in the configuration register (config.window) z time-out period in the configuration register (config.per) z early warning interrupt time offset bits in the earl y warning interrupt control register (ewctrl.ewoffset) for more information about fuse locations, see ?non-volatile memory (nvm) user row mapping? on page 22 . 17.6.2.3 enabling and disabling the wdt is enabled by writing a one to the enable bit in the control register (ctrl.enable). the wdt is disabled by writing a zero to ctrl.enable. the wdt can be disabled only while the always-on bit in the control register (ctrl.alwayson) is zero. 17.6.2.4 normal mode in normal-mode operation, the length of a time-out period is configured in config.per. the wdt is enabled by writing a one to the enable bit in the control register (ctrl.enab le). once enabled, if the wdt is not cleared from the application code before the time-out occurs, the wdt will issue a system reset. there are 12 possible wdt time-out (to wdt ) periods, selectable from 8ms to 16s, and the wdt can be cleared at any time during the time-out period. a new wdt time-out period will be started each time the wdt is clear ed by writing 0xa5 to the clear register (clear - refer to clear ). writing any value other than 0xa5 to clear will issue an immediate system reset. by default, wdt issues a system reset upon a time-out, and the early warning interrupt is disabled. if an early warning interrupt is required, the early warning interrupt enable bi t in the interrupt enable register (intenset.ew) must be enabled. writing a one to the early warning interrupt bit in the interrupt enable set register (intenset.ew) enables the interrupt, and writing a one to the early warning interrupt bit in the interrupt enable clear register (intenclr.ew) disables the interrupt. if the early warning interrupt is enabled, an interrupt is generated prior to a watchdog time-out condition. in normal mode, the early warning offset bi ts in the early warning interrupt control register (ewctrl.ewoffset) define the time where the early warning interrupt occurs. the normal-mode operation is illustrated in figure 17-2 .
181 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 17-2. normal-mode operation 17.6.2.5 window mode in window-mode operation, the wdt uses two different ti me-out periods, a closed window time-out period (to wdtw ) and the normal, or open, time-out period (to wdt ). the closed window time-out period defines a duration from 8ms to 16s where the wdt cannot be reset. if the wdt is cleared during this period, the wdt will issue a system reset. the normal wdt time-out period, which is also from 8ms to 16s, defines the duration of the open period during which the wdt can be cleared. the open period will always follow the closed period, and so the total duration of the time-out period is the sum of the closed window and the open window time-out peri ods. the closed window is defined by the window period bits in the configuration register (config.window), and the open window is defined by the period bits in the configuration register (config.per). by default, the wdt issues a system reset upon a time-out and the early warning interrupt is disabled. if an early warning interrupt is required, intenclr/set.ew must be set. writing a one to inte nset.ew enables the interrupt, and writing a one to intenclr.ew disables the interrupt. if the early warning interrupt is enabled in window mode, the interrupt is generated at the start of the open window period. the window mode operation is illustrated in figure 17-3 . figure 17-3. window-mode operation t [ms] wdt count 510 15 20 25 30 35 per[3:0]=1 timely wdt clear to wdt wdt timeout system reset ewoffset[3:0]=0 early warning interrupt t [ms] wdt count 510 15 20 25 30 35 window[3:0]=0 per[3:0]=0 timely wdt clear closed to wdtw open to wdt early wdt clear wdt timeout early warning interrupt
182 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.6.3 additional features 17.6.3.1 always-on mode the always-on mode is enabled by writing a one to the always-o n bit in the control register (ctrl.alwayson). when the always-on mode is enabled, the wdt runs continuously, regardless of the state of ctrl.enable. once written, the always-on bit can only be cleared by a power-on reset. the configuration (config) and early warning control (ewctrl) registers are read-only register s while the ctrl.alwayson bit is set. thus, the time period configuration bits (config.per, config.window, ewctrl .ewoffset) of the wdt cannot be changed. enabling or disabling window-mode operati on by writing the window enable bit (c trl.wen) is allowed while in the always-on mode, but note that config.per cannot be changed. the interrupt clear and interrupt set registers are accessible in the always-on mode. the early warning interrupt can still be enabled or disabled while in the always-on mode, but note that ewctrl.ewoffset cannot be changed. table 17-2 shows the operation of the wdt when ctrl.alwayson is set. table 17-2. wdt operating modes with always-on 17.6.4 interrupts the wdt has the following interrupt sources: z early warning each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the wdt is reset. see intflag for details on how to clear interrupt flags. the wdt has one common interrupt request line for all the inte rrupt sources. the user mu st read intflag to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. the early warning interrupt behaves differently in normal mode and in window mode. in normal mode, the early warning interrupt generation is defined by the early warning offset in the early warning control register (ewctrl.ewoffset). the early warning offset bits define the number of gclk_wdt clocks before the interrupt is generated, relative to the start of the watchdog time-out period. for example, if the wdt is operating in normal mode with config.per = 0x2 and ewctrl.ewoffset = 0x1, the early warning interrupt is generated 16 gclk_wdt clock cycles from the start of the watchdog time-out period, and the watchdog time-out system reset is generated 32 gclk_wdt clock cycles from the start of the watchdog time-out period. the user must take caution when programming the early warning offset bits. if these bits define an early warning interrupt generation time greater than the watchdog time-out period, the watchdog time-out system reset is generated prior to the early warning interrupt. thus, the early warning interrupt will never be generated. wen interrupt enable mode 0 0 always-on and normal mode 0 1 always-on and normal mode with early warning interrupt 1 0 always-on and window mode 1 1 always-on and window mode with early warning interrupt
183 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 in window mode, the early warning interrupt is generated at the start of the open window period. in a typical application where the system is in sleep mode, it can use this interrupt to wake up and clear the watchdog timer, after which the system can perform other tasks or return to sleep mode. 17.6.5 synchronization due to the asynchronicity between clk_wdt_apb and gclk_wdt some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register(status.syncbusy) will be set immediately, and cleared when synchronization is complete. the synchronization ready interrupt can be used to signal when sync is complete. this can be accessed via the synchronization ready interrupt flag in the interrupt flag status and clear register (intflag.syncrdy). if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following registers need synchronization when written: z control register (ctrl) z clear register (clear) write-synchronization is denoted by the write-synchronized property in the register description.
184 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.7 register summary register summary offset name bit pos. 0x0 ctrl 7:0 alwayson wen enable 0x1 config 7:0 window[3:0] per[3:0] 0x2 ewctrl 7:0 ewoffset[3:0] 0x3 reserved 0x4 intenclr 7:0 ew 0x5 intenset 7:0 ew 0x6 intflag 7:0 ew 0x7 status 7:0 syncbusy 0x8 clear 7:0 clear[7:0]
185 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 179 for details. some registers require synchronization when read and/or wr itten. synchronization is denoted by the write-synchronized or the read-synchronized property in each individual register description. refer to ?synchronization? on page 183 for details. some registers are enable-protected, meaning they can be wr itten only when the wdt is disabled. enable-protection is denoted by the enable-protected property in each individual register description.
186 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.1 control name: ctrl offset: 0x0 reset: n/a - loaded from nvm user row at startup property: write-protected, enable-protected, write-synchronized z bit 7 ? alwayson: always-on this bit allows the wdt to run continuously. after being written to one, this bit cannot be written to zero, and the wdt will remain enabled until a power-on reset is received. w hen this bit is one, the control register (ctrl), the configuration register (config) and the early warni ng control register (ewctrl) will be read-only, and any writes to these registers are not allowed. writing a zero to this bit has no effect. 0: the wdt is enabled and disabled through the enable bit. 1: the wdt is enabled and can only be disabled by a power-on reset (por). this bit is not enable-protected. these bits are loaded from nvm user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bits 6:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? wen: watchdog timer window mode enable the initial value of this bit is loaded from flash calibration. 0: window mode is disabled (normal operation). 1: window mode is enabled. this bit is loaded from nvm user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bit 1 ? enable: enable this bit enables or disables the wdt. can only be written while ctrl.alwayson is zero. 0: the wdt is disabled. 1: the wdt is enabled. due to synchronization, there is delay from writing ctrl.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately, and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. this bit is not enable-protected. this bit is loaded from nvm user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit76543210 alwayson wen enable access r/w1 r/w r/w r/w r/w r/w r/w r/w resetx0000xx0
187 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.2 configuration name: config offset: 0x1 reset: n/a - loaded from nvm user row at startup property: write-protected, enable-protected, write-synchronized z bits 7:4 ? window[3:0]: window mode time-out period in window mode, these bits determine the watchdog closed window period as a number of oscillator cycles. the closed window periods are defined in table 17-3 . these bits are loaded from nvm user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. z bits 3:0 ? per[3:0]: time-out period these bits determine the watchdog time-out period as a number of gclk_wdt clock cycles. in window mode operation, these bits define the open window period. the different typical time-out periods are found in table 17-4 . these bits are loaded from nvm user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. bit76543210 window[3:0] per[3:0] access r/w r/w r/w r/w r/w r/w r/w r/w resetxxxxxxxx table 17-3. window mode time-out period value description 0x0 8 clock cycles 0x1 16 clock cycles 0x2 32 clock cycles 0x3 64 clock cycles 0x4 128 clock cycles 0x5 256 clocks cycles 0x6 512 clocks cycles 0x7 1024 clock cycles 0x8 2048 clock cycles 0x9 4096 clock cycles 0xa 8192 clock cycles 0xb 16384 clock cycles 0xc-0xf reserved
188 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 17-4. time-out period value description 0x0 8 clock cycles 0x1 16 clock cycles 0x2 32 clock cycles 0x3 64 clock cycles 0x4 128 clock cycles 0x5 256 clocks cycles 0x6 512 clocks cycles 0x7 1024 clock cycles 0x8 2048 clock cycles 0x9 4096 clock cycles 0xa 8192 clock cycles 0xb 16384 clock cycles 0xc-0xf reserved
189 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.3 early warning interrupt control name: ewctrl offset: 0x2 reset: n/a - loaded from nvm user row at startup property: write-protected, enable-protected z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:0 ? ewoffset[3:0]: earl y warning interrupt time offset these bits determine the number of gclk_wdt clocks in th e offset from the start of the watchdog time-out period to when the early warning interrupt is generated. the early warning offset is defined in table 17-5 . these bits are loaded from nvm user row at startup. refer to ?non-volatile memory (nvm) user row mapping? on page 22 for more details. bit76543210 ewoffset[3:0] acces s rrrrr/wr/wr/wr/w reset0 0 0 0xxxx table 17-5. early warning interrupt time offset value description 0x0 8 clock cycles 0x1 16 clock cycles 0x2 32 clock cycles 0x3 64 clock cycles 0x4 128 clock cycles 0x5 256 clocks cycles 0x6 512 clocks cycles 0x7 1024 clock cycles 0x8 2048 clock cycles 0x9 4096 clock cycles 0xa 8192 clock cycles 0xb 16384 clock cycles 0xc-0xf reserved
190 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.4 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x4 reset: 0x00 property: write-protected z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? ew: early warning interrupt enable 0: the early warning interrupt is disabled. 1: the early warning interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit disables the early warning interrupt. bit76543210 ew accessrrrrrrrr/w reset00000000
191 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.5 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x5 reset: 0x00 property: write-protected z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? ew: early warning interrupt enable 0: the early warning interrupt is disabled. 1: the early warning interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit enables the early warning interrupt. bit76543210 ew accessrrrrrrrr/w reset00000000
192 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.6 interrupt flag status and clear name: intflag offset: 0x6 reset: 0x00 property: ? z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. these bits will always return zero when read. z bit 0 ? ew: early warning this flag is set when an early warning interrupt occurs, as defined by the ewoffset bit group in ewctrl . writing a zero to this bit has no effect. writing a one to this bit clears the early warning interrupt flag. bit76543210 ew accessrrrrrrrr/w reset00000000
193 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.7 status name: status offset: 0x7 reset: 0x00 property: ? z bit 7 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit 76543210 syncbusy accessrrrrrrrr reset00000000
194 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17.8.8 clear name: clear offset: offset: 0x8 reset: 0x00 property: write-protected, write-synchronized z bits 7:0 ? clear: watchdog clear writing 0xa5 to this register will clear the watchdog ti mer and the watchdog time-out period is restarted. writing any other value will issue an immediate system reset. bit 76543210 clear[7:0] accesswwwwwwww reset00000000
195 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18. rtc ? real-time counter 18.1 overview the real-time counter (rtc) is a 32-bit c ounter with a 10-bit programmable prescaler that typically runs continuously to keep track of time. the rtc can wake up the device from sl eep modes using the alarm/compare wake up, periodic wake up or overflow wake up mechanisms. the rtc can generate periodic peripheral events from outputs of the prescaler, as well as alarm/compare interrupts and peripheral events, which can trigger at any counter value. additionally, the timer can trigger an overflow interrupt and peripheral event, and be reset on the occurrence of an alarm/compare match. this allows periodic interrupts and peripheral events at very long and accurate intervals. the 10-bit programmable prescaler can scale down the cloc k source, and so a wide range of resolutions and time-out periods can be configured. with a 32.768khz clock source, t he minimum counter tick interval is 30.5s, and time-out periods can range up to 36 hours. with the counter tick interval configured to 1s, the maximum time-out period is more than 136 years. 18.2 features z 32-bit counter with 10-bit prescaler z multiple clock sources z 32-bit or 16-bit counter mode z one 32-bit or two 16-bit compare values z clock/calendar mode z time in seconds, minu tes and hours (12/24) z date in day of month, month and year z leap year correction z digital prescaler correction/tuning for increased accuracy z overflow, alarm/compare match and prescaler interrupts and events z optional clear on alarm/compare match 18.3 block diagram figure 18-1. rtc block diagram (mode 0 ? 32-bit counter) count compn = compare n overflow 0 matchclr 10-bit prescaler gclk_rtc clk_rtc_cnt 32 periodic events 32
196 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 18-2. rtc block diagram (mode 1 ? 16-bit counter) figure 18-3. rtc block diagram (mode 2 ? clock/calendar) 18.4 signal description not applicable. 18.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 18.5.1 i/o lines not applicable. 18.5.2 power management the rtc can continue to operate in any sleep mode. the rtc interrupts can be used to wake up the device from sleep modes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. the rtc will be reset only at power-on (por) or by writing a one to the software reset bit in the control register (ctrl.swrst). 10-bit prescaler gclk_rtc count per overflow 0 compn compare n clk_rtc_cnt 16 periodic events 16 16 = = clock alarmn = alarm n overflow 0 matchclr 10-bit prescaler gclk_rtc clk_rtc_cnt 32 periodic events 32 maskn y/m/d h:m:s y/m/d h:m:s
197 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.5.3 clocks the rtc bus clock (clk_rtc_apb) can be enabled and dis abled in the power manager, and the default state of clk_rtc_apb can be found in the peripheral clock masking section in the ?pm ? power manager? on page 101 . a generic clock (gclk_rtc) is required to clock the rtc. this clock must be configured and enabled in the generic clock controller before using the rtc. refer to ?gclk ? generic clock controller? on page 79 for details. this generic clock is asynchronous to the user interface cl ock (clk_rtc_apb). due to this asynchronicity, accessing certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 202 for further details. the rtc should never be used with the generic clock generator 0. 18.5.4 dma not applicable. 18.5.5 interrupts the interrupt request line is connected to the interrupt c ontroller. using the rtc interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 18.5.6 events to use the rtc event functionality, the corresponding events need to be configured in the event system. refer to ?evsys ? event system? on page 306 for details. 18.5.7 debug operation when the cpu is halted in debug mode the rtc will halt normal operation. the rtc can be forced to continue operation during debugging. refer to the dbgctrl register for details. 18.5.8 register access protection all registers with write-access are optionally write-protect ed by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register (intflag - refer to intflag ) z read request register (readreq - refer to readreq ) z status register (status - refer to status ) z debug register (dbgctrl - refer to dbgctrl ) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all wr ite-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 18.5.9 analog connections a 32.768khz crystal can be connected to the xin32 and xout32 pins, along with any required load capacitors. for details on recommended crystal characteristics and load capacitors, refer to ?electrical characteristics? on page 563 for details.
198 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.6 functional description 18.6.1 principle of operation the rtc keeps track of time in the system and enables periodi c events, as well as interrupts and events at a specified time. the rtc consists of a 10-bit prescaler that feeds a 32-bit counter. the actual forma t of the 32-bit counter depends on the rtc operating mode. 18.6.2 basic operation 18.6.2.1 initialization the following bits are enable-protected, meaning that they c an only be written when the rtc is disabled (ctrl.enable is zero): z operating mode bits in the c ontrol register (ctrl.mode) z prescaler bits in the contro l register (ctr l.prescaler) z clear on match bit in the control register (ctrl.matchclr) z clock representation bit in the control register (ctrl.clkrep) the following register is enable-protected: z event control register (evctrl - refer to evctrl ) any writes to these bits or registers when the rtc is enabl ed or being disabled (ctrl.enable is one) will be discarded. writes to these bits or registers while the rtc is being disabled will be completed after the disabling is complete. enable-protection is denoted by the enable-prot ection property in the register description. before the rtc is enabled, it must be configured, as outlined by the following steps: z rtc operation mode must be selected by writing the operating mode bit group in the control register (ctrl.mode) z clock representation must be selected by writing the clock representation bit in the control register (ctrl.clkrep) z prescaler value must be selected by writing the presca ler bit group in the control register (ctrl.prescaler) the rtc prescaler divides down the source clock for the rtc counter. the frequency of the rtc clock (clk_rtc_cnt) is given by the following formula: the frequency of the generic clock, gclk_rtc, is given by f gclk_rtc , and f clk_rtc_cnt is the frequency of the internal prescaled rtc clock, clk_rtc_cnt. note that in the clock/calendar mode, the prescaler must be configured to provide a 1hz clock to the counter for correct operation. 18.6.2.2 enabling, disabling and resetting the rtc is enabled by writing a one to the enable bit in the control register (ctrl.enable). the rtc is disabled by writing a zero to ctrl.enable. the rtc should be disabled before resetting it. the rtc is reset by writing a one to the software reset bit in the control register (ctrl.swrst). all registers in the rtc, except dbgctrl, will be reset to their initial state, and the rtc will be disabled. refer to the ctrl register for details. f clk_rtc_cnt f gclk_rtc 2 prescaler ----------------------------- =
199 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.6.3 operating modes the rtc counter supports three rtc operating modes: 32-bit counter, 16-bit counter and clock/calendar. the operating mode is selected by the operating mode bi t group in the control register (ctrl.mode). 18.6.3.1 32-bit counter (mode 0) when the rtc operating mode bits in the control register (ctrl.mode) are zero, the counter operates in 32-bit counter mode. the block diagram of this mode is shown in figure 18-1 . when the rtc is enabled, the counter will increment on every 0-to-1 transition of clk_rtc_cnt. the counter will increment until it reaches the top value of 0xffffffff, and then wrap to 0x00000000. this sets the overflow interrupt flag in the interrupt flag status and clear register (intflag.ovf). the rtc counter value can be read from or written to the counter value register (count) in 32-bit format. the counter value is continuously compared with the 32-bit compare register (comp0). when a compare match occurs, the compare 0interrupt flag in the interrupt flag status and clear register (intflag.cmp0) is set on the next 0-to-1 transition of clk_rtc_cnt. if the clear on match bit in the control register (ctrl.ma tchclr) is one, the counter is cleared on the next counter cycle when a compare match with comp0 occurs. this allows the rtc to generate periodic interrupts or events with longer periods than are possible with the prescaler event s. note that when ctrl.matchclr is one, intflag.cmp0 and intflag.ovf will both be set simultaneously on a compare match with comp0. 18.6.3.2 16-bit counter (mode 1) when ctrl.mode is one, the counter operates in 16-bit counter mode as shown in figure 18-2 . when the rtc is enabled, the counter will increment on every 0-to-1 transi tion of clk_rtc_cnt. in 16-bit counter mode, the 16-bit period register (per) holds the maximum value of the counter. the counter will increment until it reaches the per value, and then wrap to 0x0000. this sets the overflow interrupt flag in the interrupt flag status and clear register (intflag.ovf). the rtc counter value can be read from or written to the counter value register (count) in 16-bit format. the counter value is continuously compared with the 16-bit compare registers (c ompn, n=0?1). when a compare match occurs, the compare n interrupt flag in the interrupt flag status and clear register (intflag.cmpn, n=0?1) is set on the next 0-to-1 transition of clk_rtc_cnt. 18.6.3.3 clock/calendar (mode 2) when ctrl.mode is two, the counter operates in clock/calendar mode, as shown in figure 18-3 . when the rtc is enabled, the counter will increment on every 0-to-1 transi tion of clk_rtc_cnt. the selected clock source and rtc prescaler must be configured to provide a 1hz clock to the counter for correct operation in this mode. the time and date can be read from or written to the clock val ue register (clock) in a 32-bit time/date format. time is represented as: z seconds z minutes z hours hours can be represented in either 12- or 24-hour format, select ed by the clock representation bit in the control register (ctrl.clkrep). this bit can be changed only while the rtc is disabled. date is represented as: z day as the numeric day of the month (starting at 1) z month as the numeric month of the year (1 = january, 2 = february, etc.) z year as a value counting the offset from a reference value that must be defined in software the date is automatically adjusted for leap years, assuming ev ery year divisible by 4 is a leap year. therefore, the reference value must be a leap year, e.g. 2000. the rtc will increment until it reaches the top value of 23:59:59 december 31 of year 63, and then wrap to 00:00:00 january 1 of year 0. this will set the overflow interrupt flag in the interrupt flag status and clear registers (intflag.ovf).
200 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the clock value is continuously compared with the 32-bit al arm register (alarm0). when an alarm match occurs, the alarm 0 interrupt flag in the interrupt flag status and clear registers (intflag.alarmn0) is set on the next 0-to-1 transition of clk_rtc_cnt. a valid alarm match depends on the setting of the alarm mask se lection bits in the alarm 0 mask register (mask0.sel). these bits determine which time/date fields of the clo ck and alarm values are valid for comparison and which are ignored. if the clear on match bit in the control register (ctrl.ma tchclr) is one, the counter is cleared on the next counter cycle when an alarm match with alarm0 occurs. this allows the rtc to generate periodic interrupts or events with longer periods than are possible with the prescaler events (see ?periodic events? on page 200 ). note that when ctrl.matchclr is one, intflag.ala rm0 and intflag.ovf will both be set simultaneously on an alarm match with alarm0. 18.6.4 additional features 18.6.4.1 periodic events the rtc prescaler can generate events at periodic intervals, allowing flexible system tick creation. any of the upper eight bits of the prescaler (bits 2 to 9) can be the source of an event. when one of the periodic event output bits in the event control register (evctrl.pereon) is one, an event is generated on the 0-to1 transition of the related bit in the prescaler, resulting in a periodic event frequency of: f gclk_rtc is the frequency of the internal prescaler clock, gclk_rtc, and n is the position of the evctrl.pereon bit. for example, per0 will generate an event every 8 gclk_rtc cycles, per1 every 16 cycles, etc. this is shown in figure 18-4 . periodic events are independent of the prescaler setting used by the rtc counter, except if ctrl.prescaler is zero. then, no periodic events will be generated. figure 18-4. example periodic events 18.6.4.2 frequency correction the rtc frequency correction module employs periodic counter corrections to comp ensate for a too-slow or too-fast oscillator. frequency correction requires t hat ctrl.prescaler is greater than 1. the digital correction circuit adds or subtracts cycles fr om the rtc prescaler to adjust the frequency in approximately 1ppm steps. digital correction is achieved by adding or skipping a single count in the prescaler once every 1024 gclk_rtc cycles. the value bit group in the frequency co rrection register (freqcorr.value) determines the number of times the adjustment is applied over 976 of t hese periods. the resulting correction is as follows: 3 _ 2 + = n rtc gclk periodic f f gclk_rtc per0 per1 per2 per3 per4 correction in ppm freqcorr.value 1024 976 ? ----------------------------------------------------- 10 6 ppm ? =
201 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 this results in a resolution of 1.0006ppm. the sign bit in the frequency correction register (freqcorr.sign) determines the direction of the correction. a positive value will speed up the frequency, and a negative value will slow down the frequency. digital correction also affects the generation of the periodic events from the prescaler. when the correction is applied at the end of the correction cycle period, the interval between the previous periodic event and the next occurrence may also be shortened or lengthened depending on the correction value. 18.6.5 dma operation not applicable. 18.6.6 interrupts the rtc has the following interrupt sources: z overflow z compare m z alarm m z synchronization ready each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the rtc is reset. see intflag for details on how to clear interrupt flags. the rtc has one common interrupt request line for all the interrupt s ources. the user must read intflag to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 18.6.7 events the rtc can generate the following output events, which are generated in the same way as the corresponding interrupts: z overflow (ovf) z period n (pern) z compare n (cmpn) z alarm n (alarmn) output events must be enabled to be generated. writing a one to an event output bit in the event control register (evctrl.xxeo) enables the corresponding output event. writing a zero to this bit disables the corresponding output event. refer to ?evsys ? event system? on page 306 for details. 18.6.8 sleep mode operation the rtc will continue to operate in any sleep mode where the source clock is active. the rtc interrupts can be used to wake up the device from a sleep mode, or the rtc events can trigger other operations in the system without exiting the sleep mode. an interrupt request will be generated after the wake-up if the interrupt controller is configured accordingly. otherwise the cpu will wake up directly, without triggering an interrupt. in this case, the cpu will continue executing from the instruction following the entry into sleep. the periodic events can also wake up the cpu through the interrupt function of the event system. in this case, the event must be enabled and connected to an event channel with its interrupt enabled. see ?evsys ? event system? on page 306 for more information.
202 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.6.9 synchronization due to the asynchronicity between clk_rtc_apb and gc lk_rtc some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register(status.syncbusy) will be set immediately, and cleared when synchronization is complete. the synchronization ready interrupt can be used to signal when sync is complete. this can be accessed via the synchronization ready interrupt flag in the interrupt flag status and clear register (intflag.syncrdy). if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in the control register (ctrl.swrst) z enable bit in the control register (ctrl.enable) the following registers need synchronization when written: z the counter value register (count) z the clock value register (clock) z the counter period register (per) z the compare n value registers (compn) z the alarm n value registers (alarmn) z the frequency correction register (freqcorr) z the alarm n mask register (maskn) write-synchronization is denoted by the write-sync hronization property in the register description. the following registers need synchronization when read: z the counter value register (count) z the clock value register (clock) read-synchronization is denoted by the read-synchronization property in the register description.
203 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.7 register summary the register mapping depends on the operating mode bits in the control register (ctrl.mode). the register summary is presented for each of the three modes. table 18-1. register summary - mode 0 registers offset name bit pos. 0x00 ctrl 7:0 matchclr clkrep mode[1:0] enable swrst 0x01 15:8 prescaler[3:0] 0x02 readreq 7:0 addr[5:0] 0x03 15:8 rreq rcont 0x04 evctrl 7:0 pereo7 pereo6 pereo5 pereo4 pereo3 pereo2 pereo1 pereo0 0x05 15:8 ovfeo cmpeo0 0x06 intenclr 7:0 ovf syncrdy cmp0 0x07 intenset 7:0 ovf syncrdy cmp0 0x08 intflag 7:0 ovf syncrdy cmp0 0x09 reserved 0x0a status 7:0 syncbusy 0x0b dbgctrl 7:0 dbgrun 0x0c freqcorr 7:0 sign value[6:0] 0x0d reserved 0x0e reserved 0x0f reserved 0x10 count 7:0 count[7:0] 0x11 15:8 count[15:8] 0x12 23:16 count[23:16] 0x13 31:24 count[31:24] 0x14 reserved 0x15 reserved 0x16 reserved 0x17 reserved 0x18 comp0 7:0 comp[7:0] 0x19 15:8 comp[15:8] 0x1a 23:16 comp[23:16] 0x1b 31:24 comp[31:24]
204 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 18-2. register summary - mode 1 registers offset name bit pos. 0x00 ctrl 7:0 matchclr clkrep mode[1:0] enable swrst 0x01 15:8 prescaler[3:0] 0x02 readreq 7:0 addr[5:0] 0x03 15:8 rreq rcont 0x04 evctrl 7:0 pereo7 pereo6 pereo5 pereo4 pereo3 pereo2 pereo1 pereo0 0x05 15:8 ovfeo cmpeo1 cmpeo0 0x06 intenclr 7:0 ovf syncrdy cmp1 cmp0 0x07 intenset 7:0 ovf syncrdy cmp1 cmp0 0x08 intflag 7:0 ovf syncrdy cmp1 cmp0 0x09 reserved 0x0a status 7:0 syncbusy 0x0b dbgctrl 7:0 dbgrun 0x0c freqcorr 7:0 sign value[6:0] 0x0d reserved 0x0e reserved 0x0f reserved 0x10 count 7:0 count[7:0] 0x11 15:8 count[15:8] 0x12 reserved 0x13 reserved 0x14 per 7:0 per[7:0] 0x15 15:8 per[15:8] 0x16 reserved 0x17 reserved 0x18 comp0 7:0 comp[7:0] 0x19 15:8 comp[15:8] 0x1a comp1 7:0 comp[7:0] 0x1b 15:8 comp[15:8]
205 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 18-3. register summary - mode 2 registers offset name bit pos. 0x00 ctrl 7:0 matchclr clkrep mode[1:0] enable swrst 0x01 15:8 prescaler[3:0] 0x02 readreq 7:0 addr[5:0] 0x03 15:8 rreq rcont 0x04 evctrl 7:0 pereo7 pereo6 pereo5 pereo4 pereo3 pereo2 pereo1 pereo0 0x05 15:8 ovfeo alarmeo0 0x06 intenclr 7:0 ovf syncrdy alarm0 0x07 intenset 7:0 ovf syncrdy alarm0 0x08 intflag 7:0 ovf syncrdy alarm0 0x09 reserved 0x0a status 7:0 syncbusy 0x0b dbgctrl 7:0 dbgrun 0x0c freqcorr 7:0 sign value[6:0] 0x0d reserved 0x0e reserved 0x0f reserved 0x10 clock 7:0 minute[1:0] second[5:0] 0x11 15:8 hour[3:0] minute[5:2] 0x12 23:16 month[1:0] day[4:0] hour[4] 0x13 31:24 year[5:0] month[3:2] 0x14 reserved 0x15 reserved 0x16 reserved 0x17 reserved 0 x18 alarm0 7:0 minute[1:0] second[5:0] 0x19 15:8 hour[3:0] minute[5:2] 0x1a 23:16 month[1:0] day[4:0] hour[4] 0x1b 31:24 year[5:0] month[3:2] 0x1c mask0 7:0 sel[2:0]
206 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 197 for details. some registers require synchronization when read and/or wr itten. synchronization is denoted by the write-synchronized or the read-synchronized property in each individual register description. refer to ?synchronization? on page 202 for details. some registers are enable-protected, meaning they can only be written when the rtc is dis abled. enable-protection is denoted by the enable-protected property in each individual register description.
207 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.1 control 18.8.1.1 mode 0 name: ctrl offset: 0x00 reset: 0x0000 property: write-protected, enable-protected, write-synchronized z bits 15:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 11:8 ? prescaler[3:0]: prescaler these bits define the prescaling factor for the rtc clock source (gclk_rtc) to generate the counter clock (clk_rtc_cnt). these bits are not synchronized. bit151413121110 9 8 prescaler[3:0] access r r r r r/w r/w r/w r/w reset00000000 bit76543210 matchclr mode[1:0] enable swrst access r/w r r r r/w r/w r/w r/w reset00000000 table 18-4. prescaler prescaler[3:0] prescaler description 0x0 div1 clk_rtc_cnt = gclk_rtc/1 0x1 div2 clk_rtc_cnt = gclk_rtc/2 0x2 div4 clk_rtc_cnt = gclk_rtc/4 0x3 div8 clk_rtc_cnt = gclk_rtc/8 0x4 div16 clk_rtc_cnt = gclk_rtc/16 0x5 div32 clk_rtc_cnt = gclk_rtc/32 0x6 div64 clk_rtc_cnt = gclk_rtc/64 0x7 div128 clk_rtc_cnt = gclk_rtc/128 0x8 div256 clk_rtc_cnt = gclk_rtc/256 0x9 div512 clk_rtc_cnt = gclk_rtc/512 0xa div1024 clk_rtc_cnt = gclk_rtc/1024 0xb-0xf - reserved
208 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 7 ? matchclr: clear on match this bit is valid only in mode 0 and mode 2. this bi t can be written only when the peripheral is disabled. 0: the counter is not cleared on a compare/alarm 0 match. 1: the counter is cleared on a compare/alarm 0 match. this bit is not synchronized. z bits 6:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:2 ? mode[1:0]: operating mode these bits define the operating mode of the rtc. these bits are not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled or being disabled. 1: the peripheral is enabled or being enabled. due to synchronization, there is delay from writing ctrl.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately, and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. this bit is not enable-protected. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the rtc, except dbgctrl, to their initial state, and the rtc will be disabled. writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrl.swrst until the reset is complete. ctrl.swrst and status.syncbusy will both be cleared when the reset is complete. this bit is not enable-protected. table 18-5. peripheral operating mode mode[1:0] operating mode description 0x0 count32 mode 0: 32-bit counter 0x1 count16 mode 1: 16-bit counter 0x2 clock mode 2: clock/calendar 0x3 - reserved
209 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.1.2 mode 1 name: ctrl offset: 0x00 reset: 0x0000 property: write-protected, enable-protected, write-synchronized z bits 15:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 11:8 ? prescaler[3:0]: prescaler these bits define the prescaling factor for the rtc clock source (gclk_rtc) to generate the counter clock (clk_rtc_cnt). these bits are not synchronized. bit151413121110 9 8 prescaler[3:0] access r r r r r/w r/w r/w r/w reset00000000 bit76543210 mode[1:0] enable swrst access r r r r r/w r/w r/w r/w reset00000000 table 18-6. prescaler prescaler[3:0] prescaler description 0x0 div1 clk_rtc_cnt = gclk_rtc/1 0x1 div2 clk_rtc_cnt = gclk_rtc/2 0x2 div4 clk_rtc_cnt = gclk_rtc/4 0x3 div8 clk_rtc_cnt = gclk_rtc/8 0x4 div16 clk_rtc_cnt = gclk_rtc/16 0x5 div32 clk_rtc_cnt = gclk_rtc/32 0x6 div64 clk_rtc_cnt = gclk_rtc/64 0x7 div128 clk_rtc_cnt = gclk_rtc/128 0x8 div256 clk_rtc_cnt = gclk_rtc/256 0x9 div512 clk_rtc_cnt = gclk_rtc/512 0xa div1024 clk_rtc_cnt = gclk_rtc/1024 0xb-0xf - reserved
210 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:2 ? mode[1:0]: operating mode these bits define the operating mode of the rtc. these bits are not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled or being disabled. 1: the peripheral is enabled or being enabled. due to synchronization, there is delay from writing ctrl.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately, and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. this bit is not enable-protected. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the rtc, except dbgctrl, to their initial state, and the rtc will be disabled. writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrl.swrst until the reset is complete. ctrl.swrst and status.syncbusy will both be cleared when the reset is complete. this bit is not enable-protected. table 18-7. peripheral operating mode mode[1:0] operating mode description 0x0 count32 mode 0: 32-bit counter 0x1 count16 mode 1: 16-bit counter 0x2 clock mode 2: clock/calendar 0x3 - reserved
211 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.1.3 mode 2 name: ctrl offset: 0x00 reset: 0x0000 property: write-protected, enable-protected, write-synchronized z bits 15:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 11:8 ? prescaler[3:0]: prescaler these bits define the prescaling factor for the rtc clock source (gclk_rtc) to generate the counter clock (clk_rtc_cnt). these bits are not synchronized. bit151413121110 9 8 prescaler[3:0] access r r r r r/w r/w r/w r/w reset00000000 bit76543210 matchclr clkrep mode[1:0] enable swrst access r/w r/w r r r/w r/w r/w r/w reset00000000 table 18-8. prescaler prescaler[3:0] prescaler description 0x0 div1 clk_rtc_cnt = gclk_rtc/1 0x1 div2 clk_rtc_cnt = gclk_rtc/2 0x2 div4 clk_rtc_cnt = gclk_rtc/4 0x3 div8 clk_rtc_cnt = gclk_rtc/8 0x4 div16 clk_rtc_cnt = gclk_rtc/16 0x5 div32 clk_rtc_cnt = gclk_rtc/32 0x6 div64 clk_rtc_cnt = gclk_rtc/64 0x7 div128 clk_rtc_cnt = gclk_rtc/128 0x8 div256 clk_rtc_cnt = gclk_rtc/256 0x9 div512 clk_rtc_cnt = gclk_rtc/512 0xa div1024 clk_rtc_cnt = gclk_rtc/1024 0xb-0xf - reserved
212 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 7 ? matchclr: clear on match this bit is valid only in mode 0 and mode 2. this bi t can be written only when the peripheral is disabled. 0: the counter is not cleared on a compare/alarm 0 match. 1: the counter is cleared on a compare/alarm 0 match. this bit is not synchronized. z bit 6 ? clkrep: clock representation this bit is valid only in mode 2 and determines how the hours are represented in the clock value (clock) regis- ter. this bit can be written only when the peripheral is disabled. 0: 24 hour 1: 12 hour (am/pm) this bit is not synchronized. z bits 5:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:2 ? mode[1:0]: operating mode these bits define the operating mode of the rtc. these bits are not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled or being disabled. 1: the peripheral is enabled or being enabled. due to synchronization, there is delay from writing ctrl.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately, and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. this bit is not enable-protected. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the rtc, except dbgctrl, to their initial state, and the rtc will be disabled. writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrl.swrst until the reset is complete. ctrl.swrst and status.syncbusy will both be cleared when the reset is complete. this bit is not enable-protected. table 18-9. peripheral operating mode mode[1:0] operating mode description 0x0 count32 mode 0: 32-bit counter 0x1 count16 mode 1: 16-bit counter 0x2 clock mode 2: clock/calendar 0x3 - reserved
213 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.2 read request name: readreq offset: 0x02 reset: 0x0010 property: ? - z bit 15 ? rreq: read request writing a zero to this bit has no effect. writing a one to this bit requests synchronization of the register pointed to by the address bit group (read- req.addr) and sets the synchronization busy bit in the status register (status.syncbusy). z bit 14 ? rcont: read continuously writing a zero to this bit disables continuous synchronization. writing a one to this bit enables continuous synchronization of the register pointed to by readreq.addr. the register value will be synchronized automatic ally every time the register is updated. this bit is cleared when the register pointed to by readreq.addr is written. z bits 13:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:0 ? addr: address these bits select the offset of the register that needs read synchronization. in the rtc only the count and clock registers, which share the same address, are available for read synchronization. therefore, the addr bit group is a read-only constant of 0x10. bit151413121110 9 8 rreq rcont accesswr/wrrrrrr reset00000000 bit76543210 addr[5:0] accessrrrrrrrr reset00000000
214 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.3 event control 18.8.3.1 mode 0 name: evctrl offset: 0x04 reset: 0x0000 property: write-protected, enable-protected z bit 15 ? ovfeo: overflow event output enable 0: overflow event is disabled and will not be generated. 1: overflow event is enabled and will be generated for every overflow. z bits 14:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? cmpeo0: compare 0 event output enable 0: compare 0 event is disabled and will not be generated. 1: compare 0 event is enabled and will be generated for every compare match. z bits 7:0 ? pereox: periodic interval x event output enable 0: periodic interval m event is disabled and will not be generated. 1: periodic interval m event is enabled and will be generated. bit151413121110 9 8 ovfeo cmpeo0 accessr/wrrrrrrr/w reset00000000 bit76543210 pereo7 pereo6 pereo5 pereo4 pereo3 pereo2 pereo1 pereo0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
215 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.3.2 mode 1 name: evctrl offset: 0x04 reset: 0x0000 property: write-protected, enable-protected z bit 15 ? ovfeo: overflow event output enable 0: overflow event is disabled and will not be generated. 1: overflow event is enabled and will be generated for every overflow. z bits 14:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 9 ? cmpeo1: compare event output enable 1 0: compare 1 event is disabled and will not be generated. 1: compare 1 event is enabled and will be generated for every compare match. z bit 8 ? cmpeo0: compare event output enable 0 0: compare 0 event is disabled and will not be generated. 1: compare 0 event is enabled and will be generated for every compare match. z bits 7:0 ? pereox: periodic interval x event output enable 0: periodic interval m event is disabled and will not be generated. 1: periodic interval m event is enabled and will be generated. bit151413121110 9 8 ovfeo cmpeo1 cmpeo0 accessr/wrrrrrr/wr/w reset00000000 bit76543210 pereo7 pereo6 pereo5 pereo4 pereo3 pereo2 pereo1 pereo0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
216 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.3.3 mode 2 name: evctrl offset: 0x04 reset: 0x0000 property: write-protected, enabled-protected z bit 15 ? ovfeo: overflow event output enable 0: overflow event is disabled and will not be generated. 1: overflow event is enabled and will be generated for every overflow. z bits 14:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? alarmeo0: alarm 0 event output enable 0: alarm 0 event is disabled and will not be generated. 1: alarm 0 event is enabled and will be generated for every alarm. z bits 7:0 ? pereox: periodic interval x event output enable 0: periodic interval n event is disabled and will not be generated. 1: periodic interval n event is enabled and will be generated. bit 151413121110 9 8 ovfeo alarmeo0 accessr/wrrrrrrr/w reset00000000 bit76543210 pereo7 pereo6 pereo5 pereo4 pereo3 pereo2 pereo1 pereo0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
217 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.4 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). 18.8.4.1 mode 0 name: intenclr offset: 0x06 reset: 0x00 property: write-protected z bit 7 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled, and an interrupt r equest will be generated when the overflow interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the overflow interrupt enable bit and disable the corresponding interrupt. z bit 6 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled, and an interrupt request will be generated when the synchroni- zation ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization ready interrupt enable bit and disable the corresponding interrupt. z bits 5:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? cmp0: compare 0 interrupt enable 0: the compare 0 interrupt is disabled. 1: the compare 0 interrupt is enabled, and an interrupt request will be generated when the compare 0 interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the compare 0 interrupt enable bit and disable the corresponding interrupt. bit76543210 ovf syncrdy cmp0 accessr/wr/wrrrrrr/w reset00000000
218 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.4.2 mode 1 name: intenclr offset: 0x06 reset: 0x00 property: write-protected z bit 7 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled, and an interrupt r equest will be generated when the overflow interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the overflow interrupt enable bit and disable the corresponding interrupt. z bit 6 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled, and an interrupt request will be generated when the synchroni- zation ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization ready interrupt enable bit and disable the corresponding interrupt. z bits 5:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? cmp1: compare 1 interrupt enable 0: the compare 1 interrupt is disabled. 1: the compare 1 interrupt is enabled, and an interrupt request will be generated when the compare 1 interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the compare 1 interrupt enable bit and disable the corresponding interrupt. z bit 0 ? cmp0: compare 0 interrupt enable 0: the compare 0 interrupt is disabled. 1: the compare 0 interrupt is enabled, and an interrupt request will be generated when the compare 0 interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the compare 0 interrupt enable bit and disable the corresponding interrupt. bit76543210 ovf syncrdy cmp1 cmp0 access r/w r/w r r r r r/w r/w reset00000000
219 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.4.3 mode 2 name: intenclr offset: 0x06 reset: 0x00 property: write-protected z bit 7 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled, and an interrupt r equest will be generated when the overflow interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the overflow interrupt enable bit and disable the corresponding interrupt. z bit 6 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled, and an interrupt request will be generated when the synchroni- zation ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization ready interrupt enable bit and disable the corresponding interrupt. z bits 5:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? alarm0: alarm 0 interrupt enable 0: the alarm 0 interrupt is disabled. 1: the alarm 0 interrupt is enabled, and an interrupt request will be generated when the alarm 0 interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit disables the alarm 0 interrupt. bit76543210 ovf syncrdy alarm0 accessr/wr/wrrrrrr/w reset00000000
220 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.5 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear (intenclr) register. 18.8.5.1 mode 0 name: intenset offset: 0x07 reset: 0x00 property: write-protected z bit 7 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the overflow interrupt enable bit and enable the overflow interrupt. z bit 6 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the synchronization ready interrupt enable bit and enable the synchronization ready interrupt. z bits 5:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? cmp0: compare 0 interrupt enable 0: the compare 0 interrupt is disabled. 1: the compare 0 interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the compare 0 interrupt enable bit and enable the compare 0 interrupt. bit76543210 ovf syncrdy cmp0 accessr/wr/wrrrrrr reset00000000
221 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.5.2 mode 1 name: intenset offset: 0x07 reset: 0x00 property: write-protected z bit 7 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the overflow interrupt bit and enable the overflow interrupt. z bit 6 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the synchronization ready interrupt enable bit and enable the synchronization ready interrupt. z bits 5:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? cmp1: compare 1 interrupt enable 0: the compare 1 interrupt is disabled. 1: the compare 1 interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the compare 1 interrupt enable bit and enable the compare 1 interrupt. z bit 0 ? cmp0: compare 0 interrupt enable 0: the compare 0 interrupt is disabled. 1: the compare 0 interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the compare 0 interrupt enable bit and enable the compare 0 interrupt. bit76543210 ovf syncrdy cmp1 cmp0 access r/w r/w r r r r r/w r/w reset00000000
222 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.5.3 mode 2 name: intenset offset: 0x07 reset: 0x00 property: write-protected z bit 7 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the overflow interrupt enable bit and enable the overflow interrupt. z bit 6 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the synchronization ready interrupt bit and enable the synchronization ready interrupt. reading this bit returns the state of the synchronization ready interrupt enable. z bits 5:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? alarm0: alarm0 interrupt enable 0: the alarm 0 interrupt is disabled. 1: the alarm 0 interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the alarm 0 interrupt enable bit and enable the alarm 0 interrupt. bit76543210 ovf syncrdy alarm0 accessr/wr/wrrrrrr/w reset00000000
223 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.6 interrupt flag status and clear 18.8.6.1 mode 0 name: intflag offset: 0x08 reset: 0x00 property: - z bit 7 ? ovf: overflow this flag is cleared by writing a one to the flag. this flag is set on the next clk_rtc_cnt cycle after an overflow condition occurs, and an interrupt request will be generated ifintenclr/set.ovf is one. writing a zero to this bit has no effect. writing a one to this bit clears the overflow interrupt flag. z bit 6 ? syncrdy: synchronization ready this flag is cleared by writing a one to the flag. this flag is set on a 1-to-0 transition of the synchroniza tion busy bit in the status register (status.syncbusy), except when caused by enable or software reset, and an interrupt request will be generated if inten- clr/set.syncrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the synchronization ready interrupt flag. z bits 5:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? cmp0: compare 0 this flag is cleared by writing a one to the flag. this flag is set on the next clk_rtc_cnt cycle after a match with the compare condition, and an interrupt request will be generated if intenclr/set.comp0 is one. writing a zero to this bit has no effect. writing a one to this bit clears the compare 0 interrupt flag. bit76543210 ovf syncrdy cmp0 access r/w r/w r r r r r r/w reset00000000
224 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.6.2 mode 1 name: intflag offset: 0x08 reset: 0x00 property: - z bit 7 ? ovf: overflow this flag is cleared by writing a one to the flag. this flag is set on the next clk_rtc_cnt cycle after an overflow condition occurs, and an interrupt request will be generated ifintenclr/set.ovf is one. writing a zero to this bit has no effect. writing a one to this bit clears the overflow interrupt flag. z bit 6 ? syncrdy: synchronization ready this flag is cleared by writing a one to the flag. this flag is set on a 1-to-0 transition of the synchroniza tion busy bit in the status register (status.syncbusy), except when caused by enable or software reset, and an interrupt request will be generated if inten- clr/set.syncrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the synchronization ready interrupt flag. z , and an interrupt request will be generated bits 5:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? cmp1: compare 1 this flag is cleared by writing a one to the flag. this flag is set on the next clk_rtc_cnt cycle after a match with the compare condition, and an interrupt request will be generated if intenclr/set.comp1 is one. writing a zero to this bit has no effect. writing a one to this bit clears the compare 1 interrupt flag. z bit 0 ? cmp0: compare 0 this flag is cleared by writing a one to the flag. this flag is set on the next clk_rtc_cnt cycle after a match with the compare condition, and an interrupt request will be generated if intenclr/set.comp0 is one. writing a zero to this bit has no effect. writing a one to this bit clears the compare 0 interrupt flag. bit76543210 ovf syncrdy cmp1 cmp0 access r/w r/w r r r r r/w r/w reset00000000
225 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.6.3 mode 2 name: intflag offset: 0x08 reset: 0x00 property: ? z bit 7 ? ovf: overflow this flag is cleared by writing a one to the flag. this flag is set on the next clk_rtc_cnt cycle after an overflow condition occurs, and an interrupt request will be generated if intenclr/set.ovf is one. writing a zero to this bit has no effect. writing a one to this bit clears the overflow interrupt flag. z bit 6 ? syncrdy: synchronization ready this flag is cleared by writing a one to the flag. this flag is set on a 1-to-0 transition of the synchroniza tion busy bit in the status register (status.syncbusy), except when caused by enable or software reset, and an interrupt request will be generated if inten- clr/set.syncrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the synchronization ready interrupt flag. z bits 5:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? alarm0: alarm 0 this flag is cleared by writing a one to the flag. this flag is set on the next clk_rtc_cnt cycle after a match with alarm0 condition occurs, and an interrupt request will be generated if intenclr/set.alarm0 is also one. writing a zero to this bit has no effect. writing a one to this bit clears the alarm 0 interrupt flag. bit76543210 ovf syncrdy alarm0 accessr/wr/wrrrrrr/w reset00000000
226 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.7 status name: status offset: 0x0a reset: 0x00 property: ? z bit 7 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit76543210 syncbusy accessrrrrrrrr reset00000000
227 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.8 debug control name: dbgctrl offset: 0x0b reset: 0x00 property: ? z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? dbgrun: run during debug this bit is not reset by a software reset. writing a zero to this bit causes the rtc to halt during debug mode. writing a one to this bit allows the rtc to continue normal operation during debug mode. bit76543210 dbgrun accessrrrrrrrr/w reset00000000
228 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.9 frequency correction name: freqcorr offset: 0x0c reset: 0x00 property: write-protected, write-synchronized z bit 7 ? sign: correction sign 0: the correction value is positive, i.e., frequency will be increased. 1: the correction value is negative, i.e., frequency will be decreased. z bits 6:0 ? value[6:0]: correction value these bits define the amount of correction applied to the rtc prescaler. 0: correction is disabled and the rtc frequency is unchanged. 1?127: the rtc frequency is adjusted according to the value. bit76543210 sign value[6:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000
229 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.10 counter value 18.8.10.1 mode 0 name: count offset: 0x10 reset: 0x00000000 property: write-protected, write-synchronized, read-synchronized z bits 31:0 ? count[31:0]: counter value these bits define the value of the 32-bit rtc counter. bit 3130292827262524 count[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 count[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 count[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 count[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
230 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.10.2 mode 1 name: count offset: 0x10 reset: 0x0000 property: write-protected, write-synchronized, read-synchronized z bits 15:0 ? count[15:0]: counter value these bits define the value of the 16-bit rtc counter. bit 151413121110 9 8 count[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 count[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
231 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.11 clock value 18.8.11.1 mode 2 name: clock offset: 0x10 reset: 0x00000000 property: write-protected, write-synchronized, read-synchronized z bits 31:26 ? year[5:0]: year the year offset with respect to the reference year (defined in software). the year is considered a leap year if year[1:0] is zero. z bits 25:22 ? month[3:0]: month 1 ? january 2 ? february ? 12 ? december z bits 21:17 ? day[4:0]: day day starts at 1 and ends at 28, 29, 30 or 31, depending on the month and year. z bits 16:12 ? hour[4:0]: hour when ctrl.clkrep is zero, the hour bit group is in 24- hour format, with values 0-23. when ctrl.clkrep is one, hour[3:0] has values 1-12 and hour[4] represents am (0) or pm (1). z bits 11:6 ? minute[5:0]: minute 0 ? 59. bit 3130292827262524 year[5:0] month[3:2] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 month[1:0] day[4:0] hour[4] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 hour[3:0] minute[5:2] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 minute[1:0] second[5:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
232 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 5:0 ? second[5:0]: second 0? 59.
233 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.12 counter period 18.8.12.1 mode 1 name: per offset: 0x14 reset: 0x0000 property: write-protected, write-synchronized z bits 15:0 ? per[15:0]: counter period these bits define the value of the 16-bit rtc period. bit 151413121110 9 8 per[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 per[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
234 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.13 compare n value 18.8.13.1 mode 0 name: compn offset: 0x18 + n*0x4 [n=0..3] reset: 0x00000000 property: write-protected, write-synchronized z bits 31:0 ? comp[31:0]: compare value the 32-bit value of compn is continuously compared with the 32-bit count value. when a match occurs, the compare n interrupt flag in the interrupt flag status and clear register (intflag.cmpn) is set on the next counter cycle, and the counter value is cleared if ctrl.matchclr is one. bit 3130292827262524 comp[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 comp[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 comp[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 comp[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
235 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.13.2 mode 1 name: compn offset: 0x18 + n*0x2 [n=0..5] reset: 0x0000 property: write-protected, write-synchronized z bits 15:0 ? comp[15:0]: compare value the 16-bit value of compn is continuously compared with the 16-bit count value. when a match occurs, the compare n interrupt flag in the interrupt flag status and clear register (intflag.cmpn) is set on the next counter cycle. bit 151413121110 9 8 comp[15:8] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit76543210 comp[7:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000
236 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.14 alarm n value 18.8.14.1 mode 2 name: alarmn offset: 0x18 + n*0x8 [n=0..3] reset: 0x00000000 property: write-protected, write-synchronized the 32-bit value of alarmn is continuously compared with the 32-bit clock value, based on the masking set by maskn.sel. when a match occurs, the alarm n interrupt flag in the interrupt flag status and clear register (intflag.alarmn) is set on the next counter cycle, and the counter is cleared if ctrl.matchclr is one. z bits 31:26 ? year[5:0]: year the alarm year. years are onl y matched if maskn.sel is 6. z bits 25:22 ? month[3:0]: month the alarm month. months are matched only if maskn.sel is greater than 4. z bits 21:17 ? day[4:0]: day the alarm day. days are matched only if maskn.sel is greater than 3. z bits 16:12 ? hour[4:0]: hour the alarm hour. hours are matched only if maskn.sel is greater than 2. z bits 11:6 ? minute[5:0]: minute the alarm minute. minutes are matched only if maskn.sel is greater than 1. bit 3130292827262524 year[5:0] month[3:2] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 month[1:0] day[4:0] hour[4] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 hour[3:0] minute[5:2] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 minute[1:0] second[5:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
237 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 5:0 ? second[5:0]: second the alarm second. seconds are matched only if maskn.sel is greater than 0.
238 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 18.8.15 alarm n mask 18.8.15.1 mode 2 name: maskn offset: 0x1c + n*0x8 [n=0..3] reset: 0x00 property: write-protected, write-synchronized z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? sel[2:0]: alarm mask selection these bits define which bit groups of alarm n are valid. bit76543210 sel[2:0] access r r r r r r/w r/w r/w reset00000000 table 18-10. alarm mask selection sel[2:0] alarm mask selection description 0x0 off alarm disabled 0x1 ss match seconds only 0x2 mmss match seconds and minutes only 0x3 hhmmss match seconds, minutes and hours only 0x4 ddhhmmss match seconds, minutes, hours and days only 0x5 mmddhhmmss match seconds, minutes, hours, days and months only 0x6 yymmddhhmmss match seconds, minutes, hours, days, months and years 0x7 - reserved
239 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19. eic ? external interrupt controller 19.1 overview the external interrupt controller (eic) allows external pins to be configured as interrupt lines. each interrupt line can be individually masked and can generate an interrupt on rising, falling or both edges, or on high or low levels. each external pin has a configurable filter to remove spikes. each exter nal pin can also be configured to be asynchronous in order to wake up the device from sleep modes where all clocks have been disabled. external pins can also generate an event. a separate non-maskable interrupt (nmi) is also supported. it has properties similar to the other external interrupts, but is connected to the nmi request of the cpu, enabling it to interrupt any other interrupt mode. 19.2 features z 16 external pins, plus one non-maskable pin z dedicated interrupt line for each pin z individually maskable interrupt lines z interrupt on rising, falling or both edges z interrupt on high or low levels z asynchronous interrupts for sleep modes without clock z filtering of external pins z event generation z configurable wake-up for sleep modes 19.3 block diagram figure 19-1. eic block diagram fil ter ed g e / level detection i nterru pt wak e e vent filtenx extintx intre q_ extint [ x ] inwake _ extint [ x ] e vt _ extint [ x ] fil t e r edge/level de t ec t io n i nterrup t w a k e n mifilten nmi s en s e[2:0] nmi intre q_ nm i inwake_nmi sensex [ 2:0 ]
240 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 19.5 product dependencies in order to use this eic, other parts of the system must be configured correctly, as described below. 19.5.1 i/o lines using the eic?s i/o lines requires the i/o pins to be configured. refer to ?port? on page 280 for details. 19.5.2 power management all interrupts are available in all sleep modes, but the eic can be configured to automatically mask some interrupts in order to prevent device wake-up. the eic will continue to operate in any sleep mode where the selected source clock is running. the eic?s interrupts can be used to wake up the device from sleep modes. events connect ed to the event system can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 19.5.3 clocks the eic bus clock (clk_eic_apb) can be enabled and disabled in the power manager, and the default state of clk_eic_apb can be found in the peripheral clock masking section in ?pm ? power manager? on page 101 . a generic clock (gclk_eic) is required to clock the per ipheral. this clock must be configured and enabled in the generic clock controller before using the peripheral. refer to ?gclk ? generic clock controller? on page 79 for details. this generic clock is asynchronous to the user interface cl ock (clk_eic_apb). due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 244 for further details. 19.5.4 interrupts there are two interrupt request lines, one for the external interrupts (extint) and one for non-maskable interrupt (nmi). the extint interrupt request line is connected to the interrupt controller. using the eic interrupt requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. the nmi interrupt request line is also connected to the interrupt controller, but does not require the interrupt to be configured. 19.5.5 events the events are connected to the event system. using the ev ents requires the event system to be configured first. the external interrupt controller generates events as pulses. refer to ?evsys ? event system? on page 306 for details. signal name type description extint[15..0] digital input external interrupt pin nmi digital input non-maskable interrupt pin
241 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.5.6 debug operation when the cpu is halted in debug mode, the eic continues normal operation. if the eic is configured in a way that requires it to be periodically serviced by the cpu through inte rrupts or similar, improper operation or data loss may result during debugging. 19.5.7 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register (intflag - refer to intflag ) z non-maskable interrupt flag status and clear register (nmiflag - refer to nmiflag ) write-protection is denoted by the write-protected property in the register description. write-protection does not apply to accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 19.5.8 analog connections not applicable. 19.6 functional description 19.6.1 principle of operation the eic detects edge or level condition to generate interrupts to the cpu interrupt controller or events to the event system. each external interrupt pin (extint) can be filter ed using majority vote filtering, clocked by generic clock gclk_eic. 19.6.2 basic operation 19.6.2.1 initialization the eic must be initialized in the following order: 1. enable clk_eic_apb 2. if edge detection or filtering is required, gclk_eic must be enabled 3. write the eic configuration registers (evctrl, wakeup, configy) 4. enable the eic when nmi is used, gclk_eic must be enabled after eic configuration (nmictrl). 19.6.2.2 enabling, disabling and resetting the eic is enabled by writing a one to the enable bit in the control register (ctrl.enable). the eic is disabled by writing a zero to ctrl.enable. the eic is reset by writing a one to the software reset bit in the control register (ctrl.swrst). all registers in the eic will be reset to their initial state, and the eic will be disabled. refer to ctrl register for details. 19.6.3 external pin processing each external pin can be configured to generate an interrupt/event on edge detection (rising, falling or both edges) or level detection (high or low). the sense of external pins is c onfigured by writing the interrupt sense x bits in the config y register (configy.sensex). the corr esponding interrupt flag (intflag.extint[x]) in the interrupt flag status and clear register (intflag) is set when the interrupt conditi on is met (configy.sensex must be different from zero).
242 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 when the interrupt has been cleared in edge-sensitive mode, intflag.extint[x] will only be set if a new interrupt condition is met. in level-sensitive mode, when interrupt has been cleared, intflag.extint[x] will be set immediately if the extintx pin still matches the interrupt condition. each external pin can be filtered by a majority vote filtering, clocked by gclk_eic. filteri ng is enabled if bit filter enable x in the configuration y register (configy.filtenx) is writt en to one. the majority vote filter samples the external pin three times with gclk_eic and outputs the value when two or more samples are equal. when an external interrupt is configured for level detection, or if filtering is disabled, detection is made asynchronously, and gclk_eic is not required. if filtering or edge detection is enabled, the eic automatically requests the gclk_eic to operate (gclk_eic must be enabled in the gclk module, see ?gclk ? generic clock controller? on page 79 for details). if level detection is enabled, gclk_eic is not required, but interrupt and events can still be generated. figure 19-2. interrupt detections the detection delay depends on the detection mode. table 19-1. majority vote filter samples [0, 1, 2] filter output [0,0,0] 0 [0,0,1] 0 [0,1,0] 0 [0,1,1] 1 [1,0,0] 0 [1,0,1] 1 [1,1,0] 1 [1,1,1] 1 g clk _ ei c c lk_ei c _apb e xtint x i ntreq_ext i nt [ x ] (level detection / no filter) i ntre q_ extint [ x ] (level detection / filter ) i ntre q_ extint [ x ] ( edge detection / no f ilter ) i ntre q_ extint [ x ] (edge detection / filter ) n o interru p t n o interru p t c lear intflag.extint [ x ]
243 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.6.4 additional features the non-maskable interrupt pin can also generate an interrupt on edge or level detection, but it is configured with the dedicated nmi control register (nmictrl - refer to nmictrl ). to select the sense for nmi, write to the nmisense bit group in the nmi control register (nmictrl.nmisense). nm i filtering is enabled by writing a one to the nmi filter enable bit (nmictrl.nmifilten). nmi detection is enabled only by the nmictrl.nmisense value, and the eic is not required to be enabled. after reset, nmi is configured to no detection mode. when an nmi is detected, the non-maskable interrupt flag in the nmi flag status and clear register is set (nmiflag.nmi). nmi interrupt generation is always enabled, and nmiflag.nmi generates an interrupt request when set. 19.6.5 interrupts the eic has the following interrupt sources: z external interrupt pins (extintx). see ?basic operation? on page 241 z non-maskable interrupt pin (nmi). see ?additional features? on page 243 each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when an interrupt condition occurs (nmiflag for nmi). each interrupt, except nmi, can be individually enabled by writing a one to the corresponding bit in the interrupt enable set register (intenset), and disabled by writing a one to the corresponding bit in the interr upt enable clear register (intenclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the inte rrupt is disabled or the eic is reset. see the intflag register for details on how to clear interrupt flags. the eic has one common interr upt request line for all the interrupt sources (except the nmi interrupt request line). refer to ?processor and architecture? on page 24 for details. the user must read the intflag (or nmiflag) register to dete rmine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?processor and architecture? on page 24 for details. 19.6.6 events the eic can generate the following output events: z external event from pin (extintx). writing a one to an event output control register (evctr lextinteo) enables the corresponding output event. writing a zero to this bit disables the corresponding output event. refer to ?evsys ? event system? on page 306 for details on configuring the event system. when the condition on pin extintx matches the configurati on in the configy register, the corresponding event is generated, if enabled. table 19-2. interrupt latency detection mode latency (worst case) level without filter 3 clk_eic_apb periods level with filter 4 gclk_eic periods + 3 clk_eic_apb periods edge without filter 4 gclk_eic periods + 3 clk_eic_apb periods edge with filter 6 gclk_eic periods + 3 clk_eic_apb periods
244 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.6.7 sleep mode operation in sleep modes, an extintx pin can wake up the device if the corresponding condition matches the configuration in configy register. writing a one to a wake-up enable bi t (wakeup.wakeupen[x]) enabl es the wake-up from pin extintx. writing a zero to a wake-up enable bit (wakeu p.wakeupen[x]) disables the wake-up from pin extintx. using wakeupen[x]=1 with in tenset=0 is not recommended. figure 19-3. wake-up operation example (high- level detection, no filter, wakeupen[x]=1) 19.6.8 synchronization due to the asynchronicity between clk_eic_apb and gclk_eic, some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled, and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in the control register (ctrl.swrst) z enable bit in the control register (ctrl.enable) no register needs synchronization when written. no register needs synchronization when read. clk _ eic _ apb extintx intwake_extint[x] intre q_ extint [ x ] c lear intflag.extint [ x ] r eturn to slee p mode
245 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.7 register summary table 19-3. register summary offset name bit pos. 0x00 ctrl 7:0 enable swrst 0x01 status 7:0 syncbusy 0x02 nmictrl 7:0 nmifilten nmisense[2:0] 0x03 nmiflag 7:0 nmi 0x04 evctrl 7:0 extinteo[7:0] 0x05 15:8 extinteo[15:8] 0x06 23:16 0x07 31:24 0x08 intenclr 7:0 extint[7:0] 0x09 15:8 extint[15:8] 0x0a 23:16 0x0b 31:24 0x0c intenset 7:0 extint[7:0] 0x0d 15:8 extint[15:8] 0x0e 23:16 0x0f 31:24 0x10 intflag 7:0 extint[7:0] 0x11 15:8 extint[15:8] 0x12 23:16 0x13 31:24 0x14 wakeup 7:0 wakeupen[7:0] 0x15 15:8 wakeupen[15:8] 0x16 23:16 0x17 31:24 0x18 config0 7:0 filten1 sense1[2:0] filten0 sense0[2:0] 0x19 15:8 filten3 sense3[2:0] filten2 sense2[2:0] 0x1a 23:16 filten5 sense5[2:0] filten4 sense4[2:0] 0x1b 31:24 filten7 sense7[2:0] filten6 sense6[2:0] 0x1c config1 7:0 filten9 sense9[2:0] filten8 sense8[2:0] 0x1d 15:8 filten11 sense11[2:0] filten10 sense10[2:0] 0x1e 23:16 filten13 sense13[2:0] filten12 sense12[2:0] 0x1f 31:24 filten15 sense15[2:0] filten14 sense14[2:0]
246 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each indi vidual register description. refer to ?register access protection? on page 241 for details. some registers require synchronization when read and/or written. synchronization is denoted by the synchronized property in each individual register description. refer to ?synchronization? on page 244 for details. some registers are enable-protected, meaning they can be wr itten only when the eic is disabled. enable-protection is denoted by the enabled-protected property in each individual register description.
247 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.1 control name: ctrl offset: 0x00 reset: 0x00 property: write-protected,write-synchronized z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? enable: enable 0: the eic is disabled. 1: the eic is enabled. due to synchronization, there is delay from writing ctrl.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately, and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. z bit 0 ? swrst: software reset 0: there is no ongoing reset operation. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the eic to their initial state, and the eic will be disabled. writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write opera- tion will be discarded. due to synchronization, there is a delay from writing ctrl.swrst until the reset is complete. ctrl.swrst and status.syncbusy will both be cleared when the reset is complete. bit 76543210 enable swrst accessrrrrrrr/wr/w reset00000000
248 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.2 status name: status offset: 0x01 reset: 0x00 property: - z bit 7 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit 7 6543210 syncbusy accessr rrrrrrr reset0 0000000
249 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.3 non-maskable interrupt control name: nmictrl offset: 0x02 reset: 0x00 property: write-protected z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? nmifilten: non-maskab le interrupt filter enable 0: nmi filter is disabled. 1: nmi filter is enabled. z bits 2:0 ? nmisense: non -maskable interrupt sense these bits define on which edge or level the nmi triggers. bit 76543210 nmifilten nmisense[2:0] accessrrrrr/wr/wr/wr/w reset00000000 table 19-4. nmi sense configuration nmisense name description 0x0 none no detection 0x1 rise rising-edge detection 0x2 fall falling-edge detection 0x3 both both-edges detection 0x4 high high-level detection 0x5 low low-level detection 0x6-0x7 - reserved
250 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.4 non-maskable interrupt flag status and clear name: nmiflag offset: 0x03 reset: 0x00 property: - z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? nmi: non-maskable interrupt this flag is cleared by writing a one to it. this flag is set when the nmi pin matches the nmi sense configuration, and will generate an interrupt request. writing a zero to this bit has no effect. writing a one to this bit clears the non-maskable interrupt flag. bit 76543210 nmi accessrrrrrrrr/w reset 00000000
251 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.5 event control name: evctrl offset: 0x04 reset: 0x00000000 property: write-protected z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:0 ? extinteo: external interrupt x event output enable these bits indicate whether the event associated with the extintx pin is enabled or not to generated for every detection. 0: event from pin extintx is disabled. 1: event from pin extintx is enabled. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 extinteo[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 extinteo[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
252 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.6 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x08 reset: 0x00000000 property: write-protected z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:0 ? extint: external interrupt x enable 0: the external interrupt x is disabled. 1: the external interrupt x is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the external interr upt x enable bit, which enables the external interrupt. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 extint[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 extint[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
253 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.7 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear (intenclr) register. name: intenset offset: 0x0c reset: 0x00000000 property: write-protected z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:0 ? extint: external interrupt x enable 0: the external interrupt x is disabled. 1: the external interrupt x is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the external interr upt x enable bit, which enables the external interrupt. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 extint[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 extint[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
254 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.8 interrupt flag status and clear name: intflag offset: 0x10 reset: 0x00000000 property: - z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:0 ? extint: external interrupt x this flag is cleared by writing a one to it. this flag is set when extintx pin matches the external interrupt sense configuration and will generate an interrupt request if intenclr/set.extint[x] is one. writing a zero to this bit has no effect. writing a one to this bit clears the external interrupt x flag. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 extint[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 extint[7:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000
255 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.9 wake-up enable name: wakeup offset: 0x14 reset: 0x00000000 property: write-protected z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:0 ? wakeupen: external interrupt x wake-up enable this bit enables or disables wake-up from sleep modes when the extintx pin matches the external interrupt sense configuration. 0: wake-up from the extintx pin is disabled. 1: wake-up from the extintx pin is enabled. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 wakeupen[15:8] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit 76543210 wakeupen[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
256 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 19.8.10 configuration n name: confign offset: 0x18+n*0x4 [n=0..1] reset: 0x00000000 property: write-protected z bits 31, 27, 23, 19, 15, 11, 7, 3 ? filtenx [x=7..0]: filter x enable 0: filter is disabled for extint[n*8+x] input. 1: filter is enabled for extint[n*8+x] input. z bits 30:28, 26:24, 22:20, 18:16, 14:12, 10:8, 6:4, 2:0 ? sensex[2:0] [x=7..0]: input sense x configuration these bits define on which edge or level the interrupt or event for extint[n*8+x] will be generated. bit 3130292827262524 filten7 sense7[2:0] filten6 sense6[2:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 filten5 sense5[2:0] filten4 sense4[2:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 filten3 sense3[2:0] filten2 sense2[2:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit 76543210 filten1 sense1[2:0] filten0 sense0[2:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
257 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 19-5. sense configuration sense name description 0x0 none no detection 0x1 rise rising-edge detection 0x2 fall falling-edge detection 0x3 both both-edges detection 0x4 high high-level detection 0x5 low low-level detection 0x6-0x7 - reserved
258 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20. nvmctrl ? non-volat ile memory controller 20.1 overview non-volatile memory (nvm) is a repr ogrammable flash memory that retains program and data storage even with power off. the nvm controller (nvmctrl) connects to the ahb and apb bus interfaces for system access to the nvm block. the ahb interface is used for reads and writes to the nvm block, while the apb interface is used for commands and configuration. 20.2 features z 32-bit ahb interface for reads and writes z all nvm sections are memory mapped to the ahb, including calibration and system configuration z 32-bit apb interface for commands and control z programmable wait states for read optimization z 16 regions can be individually protected or unprotected z additional protection for boot loader z supports device protection through a security bit z interface to power manager for power-down of flash blocks in sleep modes z can optionally wake up on exit from sleep or on first access z direct-mapped cache 20.3 block diagram figure 20-1. block diagram 20.4 signal description not applicable command and control nvm interface cache nvm block nvmctrl ahb apb
259 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 20.5.1 power management the nvmctrl will continue to operate in any sleep mode where the selected source clock is running. the nvmctrl?s interrupts can be used to wake up the device from sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. the power manager will automatically put the nvm block into a low-power state when entering sleep mode. this is based on the control b register (ctrlb - refer to ctrlb ) sleepprm bit setting. read the ctrlb register description for more details. 20.5.2 clocks two synchronous clocks are used by the nvmctrl. one is provided by the ahb bus (clk_nvmctrl_ahb) and the other is provided by the apb bus (c lk_nvmctrl_apb). for hi gher system frequencies, a programmable number of wait states can be used to optimize performance. when changing the ahb bus frequency, the user must ensure that the nvm controller is configured with the proper number of wait states. refer to the ?electrical characteristics? on page 563 for the exact number of wait states to be used for a particular frequency range. 20.5.3 interrupts the nvm controller interrupt request line is connected to t he interrupt controller. using the nvmctrl interrupt requires the interrupt controller to be programmed first. refer to ?nested vector interrupt controller? on page 25 for details. 20.5.4 debug operation when an external debugger forces the cpu into debug mode, the peripheral continues normal operation. access to the nvm block can be protected by the security bit. in this case, the nvm block will not be accessible. see ?security bit? on page 264 for details. 20.5.5 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register (intflag - refer to intflag ) z status register (status - refer to status ) write-protection is denoted by the write-protected property in the register description. write-protection does not apply for accesses through an external debugger. when the cpu is halted in debug mode, all write-protection is automatically disabled. refer to ?pac ? peripheral access controller? on page 28 for details. 20.5.6 analog connections not applicable. 20.6 functional description 20.6.1 principle of operation the nvm controller is a slave on the ahb and apb buses. it responds to commands, read requests and write requests, based on user configuration.
260 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.6.2 basic operations 20.6.2.1 initialization after power up, the nvm controller goes through a power-up sequence. during this time, access to the nvm controller from the ahb bus is halted. upon power-up completion, th e nvm controller is operati onal without any need for user configuration. 20.6.2.2 enabling, disabling and resetting not applicable. 20.6.3 memory organization refer to ?physical memory map? on page 20 for memory sizes and addresses for each device. the nvm is organized into rows, where each row contains four pages, as shown in figure 20-2 . the nvm has a row- erase granularity, while the write granularity is by page. in other words, a single row erase will erase all four pages in the row, while four write operations are used to write the complete row. figure 20-2. row organization the nvm block contains a calibration and auxiliary space that is memory mapped. refer to figure 20-3 for details. the calibration and auxiliary space contains factory calibration and system configuration information. this space can be read from the ahb bus in the same way as the main nvm main address space. in addition, a boot loader section can be allocated at the beginning of the main array, and an eeprom emulation area can be allocated at the end of the nvm main address space. figure 20-3. nvm memory organization the lower rows in the nvm main address space can be allocated as a boot loader section by using the bootprot fuses, and the upper rows can be allocated to eeprom emulation, as shown in figure 20-4 . the boot loader section is protected by the lock bit(s) corresponding to this address space and by the bootprot[2:0] fuse. the eeprom rows can be written regardless of the region lock status. the number of rows protected by bootprot and the number of rows allocated to eeprom emulation are given in table 20-2 and table 20-3 , respectively. page (n * 4) + 0 row n page (n * 4) + 1 page (n * 4) + 2 page (n * 4) + 3 nvm base address calibration and auxiliary space nvm main address space nvm base address + nvm size nvm base address + 0x00800000
261 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 20-4. eeprom emulation and boot load er allocation 20.6.4 region lock bits the nvm block is grouped into 16 equally sized regions. t he region size is dependent on the flash memory size, and is given in the table below. each region has a dedicated lock bit preventing writing and erasing pages in the region. after production, all regions will be unlocked. table 20-1. region size to lock or unlock a region, the lock region and unlock r egion commands are provided. writing one of these commands will temporarily lock/unlock the region containing the address loaded in the addr register. addr can be written by software, or the automatically loaded value from a write operation can be used. the new setting will stay in effect until the next reset, or the setting can be changed again using the lock and unlock commands. the current status of the lock can be determined by reading the lock register. to change the default lock/unlock setting for a region, the user configuration section of the auxiliary space must be written using the write auxiliary page command. writing to the auxiliary space will take effect after the next reset. therefore, a boot of the device is needed for changes in the lock/unlock setting to take effect. see ?physical memory map? on page 20 for calibration and auxiliary space address mapping. 20.6.5 command and data interface the nvm controller is addressable from the apb bus, while the nvm main addres s space is addressable from the ahb bus. read and automatic page write operations are performed by addressing the nvm main address space directly, while other operations such as manual page writes and row erase must be performed by issuing commands through the nvm controller. nvm base address eeprom emulation allocation program allocation nvm base address + nvm size boot allocation nvm base address + bootprot size nvm base address + nvm size - eeprom size memory size [kb] region size [kb] 256 16 128 8 64 4 32 2
262 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 to issue a command, the ctrla.cmd bits must be wri tten along with the ctrla.cmdex value. when a command is issued, intflag.ready will be cleared until the command has completed. any commands written while intflag.ready is low will be ignored. read the ctrla register description for more details. the ctrlb register must be used to control the power reduction mode, read wait states and the write mode. 20.6.5.1 nvm read reading from the nvm main address space is performed via the ahb bus by addressing the nvm main address space or auxiliary address space directly. read data is available af ter the configured number of read wait states (ctrlb.rws) set in the nvm controller, has passed. the number of cycles data are delayed to the ahb bus is determined by the read wait states. examples of using zero and one wait states are shown in figure 20-5 . figure 20-5. read wait state examples 20.6.5.2 nvm write the nvm controller requires that an erase must be done before programming. the entire nvm main address space can be erased by a debugger chip erase command. alternatively, rows can be individually erased by the erase row command. after programming, the region that the page resides in can be locked to prevent spurious write or erase sequences. locking is performed on a per-region basis, and so locking a region locks all pages inside the region. data to be written to the nvm block are first written and stored in an internal buffer called the page buffer. the page buffer contains the same number of bytes as an nvm page. wr ites to the page buffer must be 16 or 32 bits. 8-bit writes to the page buffer is not allowed, and will cause a system exception. writing to the nvm block via the ahb bus is performed by a load operation to the page buffer. for each ahb bus write, the address is stored in the addr register. after the page buffer has been loaded with the required number of bytes, the page can be written to the addressed location by setting cmd to write page and setting the key value to cmdex. the load bit in the status register indicates whether the page buffer has been loaded or not. before writing the page to memory, the accessed row must be erased. by default, automatic page writes are enabled (manw=0). this will trigger a write operation to the page addressed by addr when the last location of the page is written. because the address is automatically stored in addr duri ng the i/o bus write operation, the last given address will be present in the addr register. there is no need to load the addr register manually, unless a different page in memory is to be written. rd 0 rd 1 idle data 0 data 1 1 wait state rd 0 rd 1 idle data 0 data 1 0 wait states ahb command ahb slave ready ah b slave d ata ahb command ahb slave ready ahb slave data
263 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 procedure for manual page writes (manw=1) the row to be written must be erased before the write command is given. z write to the page buffer by addressing the nvm main address space directly z write the page buffer to memory: cmd=write page and cmdex z the ready bit in the intflag register will be low while programming is in progress, and access through the ahb will be stalled procedure for automatic page writes (manw=0) the row to be written must be erased before the last write to the page buffer is performed. note that partially written pages must be written with a manual write. z write to the page buffer by addressing the nvm main address space directly. z when the last location in the page buffer is written, the page is automatically written to nvm main address space. z intflag.ready will be zero while programming is in progress and access through the ahb will be stalled. 20.6.5.3 page buffer clear the page buffer is automatically cleared to all ones after a page write is performed. if a partial page has been written and it is desired to clear the contents of the page buffer, the page buffer clear command can be used. 20.6.5.4 erase row before a page can be written, the row that contains the page must be erased. the erase row command can be used to erase the desired row. erasing the row sets all bits to one. if the row resides in a region that is locked, the erase will not be performed and the lock error bit in the stat us register (status.locke) will be set. procedure for erase row z write the address of the row to erase addr. any address within the row can be used. z issue an erase row command. 20.6.5.5 lock and unlock region these commands are used to lock and unlock regions as detailed in section ?region lock bits? on page 261 . 20.6.5.6 set and clear power reduction mode the nvm controller and block can be taken in and out of power reduction mode through the set and clear power reduction mode commands. when the nvm controller and blo ck are in power reduction mode, the power reduction mode bit in the status register (status.prm) is set. 20.6.6 nvm user configuration the nvm user configuration resides in the auxiliary space. see ?physical memory map? on page 20 for calibration and auxiliary space address mapping. the bootloader resides in the main array starting at offset zero. the allocated boot loader section is protected against write. table 20-2. boot loader size bootprot [2:0] rows protected by bootprot boot loader size in bytes 7 none 0 6 2 512 5 4 1024 4 8 2048
264 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the eeprom bits indicates the flash size re served for eeprom emulation according to the table 20-3 . eeprom resides in the upper rows of the nvm main address space and are writable, regardless of the region lock status. note: 1. the actual size of the eeprom depends on the emulation software. for more information see application note at03265 20.6.7 security bit the security bit allows the entire chip to be locked from external access for code security. the security bit can be written by a dedicated command, set security bit (ssb). once set, the only way to clear the security bit is through a debugger chip erase command. after issuing the ssb command, the proge error bit can be checked. refer to ?dsu ? device service unit? on page 37 for details. 20.6.8 cache the nvm controller cache reduces the device power consum ption and improves system performance when wait states are required. it is a direct-mapped cache that implements 8 lines of 64 bits (i.e., 64 bytes). nvm controller cache can be enabled by writing a zero in the cachedis bit in the ctrl b register (ctrlb.cachedis). cache can be configured to three different modes using the readmode bit group in the ctrlb register. refer to ctrlb register description for more details. the invall command can be issued through the ctrla register to invalidate all cache lines. commands affecting nvm content automatically invalidate cache lines. 3 16 4096 2 32 8192 1 64 16384 0 128 32768 table 20-3. flash size for eeprom emulation eeprom[2:0] rows allocated to eeprom eeprom size in bytes for eeprom emulation (1) 7 none 0 6 1 256 5 2 512 4 4 1024 3 8 2048 2 16 4096 1 32 8192 0 64 16384 bootprot [2:0] rows protected by bootprot boot loader size in bytes
265 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.7 register summary offset name bit pos. 0x00 ctrla 7:0 cmd[6:0] 0x01 15:8 cmdex[7:0] 0x2 reserved 0x3 reserved 0x04 ctrlb 7:0 manw rws[3:0] 0x05 15:8 sleepprm[1:0] 0x06 23:16 cachedis readmode[1:0] 0x07 31:24 0x08 param 7:0 nvmp[7:0] 0x09 15:8 nvmp[15:8] 0x0a 23:16 psz[2:0] 0x0b 31:24 0x0c intenclr 7:0 error ready 0x0d reserved 0x0e reserved 0x0f reserved 0x10 intenset 7:0 error ready 0x11 reserved 0x12 reserved 0x13 reserved 0x14 intflag 7:0 error ready 0x15 reserved 0x16 reserved 0x17 reserved 0x18 status 7:0 nvme locke proge load prm 0x19 15:8 sb 0x1a reserved 0x1b reserved 0x1c addr 7:0 addr[7:0] 0x1d 15:8 addr[15:8] 0x1e 23:16 addr[21:16] 0x1f 31:24 0x20 lock 7:0 lock[7:0] 0x21 15:8 lock[15:8] 0x22 reserved 0x23 reserved
266 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to the ?register access protection? on page 259 and the ?pac ? peripheral access controller? on page 28 for details.
267 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.1 control a name: ctrla offset: 0x00 reset: 0x0000 property: write-protected z bits 15:8 ? cmdex: command execution this bit group should be written with the key value 0xa5 to enable the command written to cmd to be executed. if the bit group is written with a different key value, the write is not performed and the proge status bit is set. proge is also set if the a previously written command is not complete. the key value must be written at the same time as cmd. if a command is issued through the apb bus on the same cycle as an ahb bus access, the ahb bus access will be given priority. the command will then be executed when the nvm block and the ahb bus are idle. the ready status must be one when the command is issued. bit 0 of the cmdex bit group will read back as one until the command is issued. z bit 7 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 6:0 ? cmd: command these bits define the command to be executed when the cmdex key is written, as shown in table 20-4 . bit151413121110 9 8 cmdex[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 cmd[6:0] access r r/w r/w r/w r/w r/w r/w r/w reset00000000 table 20-4. command bit description cmd[4:0] group configuration description 0x00-0x01 - reserved 0x02 er erase row - erases the row addressed by the addr register. 0x03 - reserved 0x04 wp write page - writes the contents of t he page buffer to the page addressed by the addr register. 0x05 ear erase auxiliary row - erases the auxiliary row addressed by the addr register. this command can be given only when the security bit is not set and only to the user configuration row.
268 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x06 wap write auxiliary page - writes the contents of the page buffer to the page addressed by the addr register. this command can be given only when the security bit is not set and only to the user configuration row. 0x07-0x3f - reserved 0x40 lr lock region - locks the region containing the address location in the addr register. 0x41 ur unlock region - unlocks the region containing the address location in the addr register. 0x42 sprm sets the power reduction mode. 0x43 cprm clears the power reduction mode. 0x44 pbc page buffer clear - clears the page buffer. 0x45 ssb set security bit - sets the security bit by writing 0x00 to the first byte in the lockbit row. 0x46 invall invalidates all cache lines. 0x46-0x7f - reserved table 20-4. command bit description (continued) cmd[4:0] group configuration description
269 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.2 control b name: ctrlb offset: 0x04 reset: 0x00000000 property: write-protected z bits 31:19 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 18 ? cachedis: cache disable this bit is used to disable the cache. 0: the cache is enabled. 1: the cache is disabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 cachedis readmode[1:0] access r r r r r r/w r/w r/w reset00000000 bit151413121110 9 8 sleepprm[1:0] accessrrrrrrr/wr/w reset00000000 bit76543210 manw rws[3:0] access r/w r r r/w r/w r/w r/w r reset00000000
270 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 17:16 ? readmode: nvmctrl read mode z bits 15:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 9:8 ? sleepprm: power reduction mode during sleep indicates the power reduction mode during sleep. table 20-5. table 1-7. power reduction mode during sleep z bit 7 ? manw: manual write 0: writing to the last word in the page buffer will automatically initiate a write operation to the page addressed in the address (addr) register. this includes writes to memory and auxiliary rows. 1: write commands must be issued through the command bit group in the control a register(ctrla.cmd). z bits 6:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:1 ? rws: nvm read wait states these bits give the number of wait states for a read operation. zero indicates zero wait states, one indicates one wait state, etc., up to 15 wait states. this register is initialized to 0 wait states. software can change this value based on the nvm access time and sys- tem frequency. z bit 0 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. readmode name description 0x0 no_miss_penalty the nvm controller (cac he system) does not in sert wait states on a cache miss. gives the best system performance. 0x1 low_power reduces power consumption of the cache system, but inserts a wait state each time there is a cache miss. this mode may not be relevant if cpu performance is required, as the application will be stalled and may lead to increase run time. 0x2 deterministic the cache system ensure s that a cache hit or miss takes the same amount of time, determined by the number of programmed flash wait states. this mode can be used for real-time applications that require deterministic execution timings. 0x3 reserved sleepprm[1:0] name description 0x0 wakeonaccess nvm block enters low-power mode when entering sleep. nvm block exits low-power mode upon first access. 0x1 wakeupinstant nvm block enters low-power mode when entering sleep. nvm block exits low-power mode when exiting sleep. 0x2 reserved 0x3 disabled auto power reduction disabled.
271 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.3 nvm parameter name: param offset: 0x08 reset: 0x000xxxxx property: ? z bits 31:19 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 18:16 ? psz: page size indicates the page size. not all device families will provide all the page sizes indicated in the table. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 psz[2:0] accessrrrrrrrr reset00000xxx bit151413121110 9 8 nvmp[15:8] accessrrrrrrrr resetxxxxxxxx bit76543210 nvmp[7:0] access r r r r r r r resetxxxxxxxx
272 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 15:0 ? nvmp: nvm pages indicates the number of pages in the nvm main address space. table 20-6. page size psz[2:0] name description 0x0 8 8 bytes 0x1 16 16 bytes 0x2 32 32 bytes 0x3 64 64 bytes 0x4 128 128 bytes 0x5 256 256 bytes 0x6 512 512 bytes 0x7 1024 1024 bytes
273 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.4 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x0c reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? error: error interrupt enable 0: error interrupt is disabled 1: error interrupt is enabled writing a zero to this bit has no effect. writing a one to this bit will clear the error interrupt enable bit, which disables the error interrupt. z bit 0 ? ready: nvm ready interrupt enable 0: nvm ready interrupt is disabled 1: nvm ready interrupt is enabled writing a zero to this bit has no effect. writing a one to this bit will clear the nvm ready interrupt enable bit, which disables the nvm ready interrupt. bit76543210 error ready accessrrrrrrr/wr/w reset00000000
274 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.5 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x10 reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? error: error interrupt enable writing a zero to this bit has no effect. writing a one to this bit sets the error interrupt enable. this bit will read as the current value of the error interrupt enable. z bit 0 ? ready: nvm ready interrupt enable writing a zero to this bit has no effect. writing a one to this bit sets the ready interrupt enable. this bit will read as the current value of the ready interrupt enable. bit76543210 error ready accessrrrrrrr/wr/w reset00000000
275 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.6 interrupt flag status and clear name: intflag offset: 0x14 reset: 0x00 property: ? z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? error: error this flag is set on the occurrence of an nvme, locke or proge error. 0: no errors have been received since the last clear. 1: at least one error has occurred since the last clear. this bit can be cleared by writing a one to its bit location. z bit 0 ? ready: nvm ready 0: the nvm controller is busy programming or erasing. 1: the nvm controller is ready to accept a new command. bit76543210 error ready accessrrrrrrr/wr reset00000000
276 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.7 status name: status offset: 0x18 reset: 0x0x00 property: ? z bits 15:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? sb: security bit status 0: the security bit is inactive. 1: the security bit is active. z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? nvme: nvm error 0: no programming or erase errors have been received from the nvm controller since this bit was last cleared. 1: at least one error has been registered from the nvm controller since this bit was last cleared. this bit can be cleared by writing a one to its bit location. z bit 3 ? locke: lock error status 0: no programming of any locked lock region has happened since this bit was last cleared. 1: programming of at least one locked lock region has happened since this bit was last cleared. this bit can be cleared by writing a one to its bit location. z bit 2 ? proge: programming error status 0: no invalid commands or bad keywords were written in the nvm command register since this bit was last cleared. 1: an invalid command and/or a bad keyword was/were wri tten in the nvm command register since this bit was last cleared. this bit can be cleared by writing a one to its bit location. z bit 1 ? load: nvm page buffer active loading this bit indicates that the nvm page buffer has been loaded with one or more words. immediately after an nvm load has been performed, this flag is set, and it remains set until a page write or a page buffer clear (pbclr) com- mand is given. bit151413121110 9 8 sb accessrrrrrrrr reset0000000x bit76543210 nvme locke proge load prm access r r r r/w r/w r/w r/w r reset00000000
277 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 this bit can be cleared by writing a one to its bit location. z bit 0 ? prm: power reduction mode this bit indicates the current nvm power reduction stat e. the nvm block can be set in power reduction mode in two ways: through the command interface or automatically when entering sleep with sleepprm set accordingly. prm can be cleared in three ways: through ahb access to the nvm block, through the command interface (sprm and cprm) or when exiting sleep with sleepprm set accordingly. 0: nvm is not in power reduction mode. 1: nvm is in power reduction mode.
278 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.8 address name: addr offset: 0x1c reset: 0x00000000 property: write-protected z bits 31:22 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 21:0 ? addr: nvm address addr drives the hardware (16-bit) address to the nv m when a command is executed using cmdex. 8-bit addresses must be shifted one bit to the right before writing to this register. this register is automatically updated when writing to the page buffer, and can also be manually written. this reg- ister holds the address offset for the section addressed. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 addr[21:16] access r r r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 addr[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 addr[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
279 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 20.8.9 lock section name: lock offset: 0x20 reset: 0xxxxx property: ? z bits 15:0 ? lock: region lock bits in order to set or clear these bits, the cmd register must be used. 0: the corresponding lock region is locked. 1: the corresponding lock region is not locked. bit151413121110 9 8 lock[15:8] accessrrrrrrrr resetxxxxxxxx bit76543210 lock[7:0] accessrrrrrrrr resetxxxxxxxx
280 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21. port 21.1 overview the port (port) controls the i/o pins of the microcontroller . the i/o pins are organized in a series of groups, collectively referred to as a line bundle, and each group can have up to 32 pins that can be configured and controlled individually or as a group. each pin may either be used for general-pur pose i/o under direct application control or assigned to an embedded device peripheral. when used for general-purpose i/o, each pin can be configured as input or output, with highly configurable driver and pull settings. all i/o pins have true read-modify-write functionality when used for general-purpose i/o; the direction or the output value of one or more pins may be changed (set, reset or toggled) without unintentionally changing the state of any other pins in the same line bundle via a single, atomic 8-, 16- or 32-bit write. the port is connected to the high-speed bus matrix through an ahb/apb bridge. the pin direction, data output value and data input value registers may also be accessed using the low-latency cpu local bus (iobus; arm ? single-cycle i/o port). 21.2 features z selectable input and output configur ation individually for each pin z software-controlled multiplexing of peripheral functions on i/o pins z flexible pin configuration through a dedicated pin configuration register z configurable output driver and pull settings: z totem-pole (push-pull) z pull configuration z driver strength z configurable input buffer and pull settings: z internal pull-up or pull-down z input sampling criteria z input buffer can be disabled if not needed for lower power consumption z read-modify-write support for pin configuration, output value and pin direction
281 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.3 block diagram figure 21-1. port block diagram 21.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 21.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 21.5.1 i/o lines the i/o lines of the port are mapped to pins of the physical device package according to a simple naming scheme. each line bundle of up to 32 pins is assigned a letter identifie r, starting with a, that monotonically increases through the alphabet for each subsequent line bundle. within each line bundle, each pin is assigned a numerical identifier according to its bit position. the resulting port pins are mapped as pxy, where x=a, b, c,? and y=00, 01, ?, 31 to uniquely identify each pin in the device, e.g., pa24, pc03, etc. each pin may have one or more peripheral multiplexer settings, which allow the pad to be routed internally to a dedicated peripheral function. when enabled, the selected peripheral is given control over the output state of the pad, as well as the ability to read the current physical pad state. refer to ?i/o multiplexing and considerations? on page 11 for details. device-specific configurations may result in some pins (and the corresponding pxy pin) not being implemented. portmux analog blocks peripherals digital controls of analog blocks analog pad connections i/o pads port line bundles ip line bundles peripheral mux select port control and status pad line bundles signal name type description pxy digital i/o general-purpose i/o pin y
282 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.5.2 power management during reset, all port lines are configured as inputs with input buffers, output buffers and pull disabled. if the port peripheral is shut down, the latches contained in the pad will retain their current configuration, such as the output value and pull settings. however, the port configuration registers and input synchronizers will lose their contents, and these will not be restored when port is power ed up again. the user must, therefore, reconfigure the port peripheral at power up to ensure it is in a well-defined state before use. the port will continue to operate in any sleep mode where the selected module source clock is running. 21.5.3 clocks the port bus clock (clk_port_apb) can be enabled and disabled in the power manager, and the default state of clk_port_apb can be found in the peripheral clock masking section in the ?pm ? power manager? on page 101 . the port is fed by two different clocks: a cpu main clock, which allows the cpu to access the port through the low- latency cpu local bus (iobus), and an apb clock, which is a divided clock of the cpu main clock and allows the cpu to access the port registers through the high-speed matrix and the ahb/apb bridge. iobus accesses have priority over apb accesses. the latter must insert wait states in the event of concurrent port accesses. the port input synchronizers use the cpu main clock so that the resynchronization delay is minimized with respect to the apb clock. 21.5.4 dma not applicable. 21.5.5 interrupts not applicable. 21.5.6 events not applicable. 21.5.7 debug operation when the cpu is halted in debug mode, the port continues normal operation. if the port is configured in a way that requires it to be periodically serviced by the cpu through inte rrupts or similar, improper operation or data loss may result during debugging. 21.5.8 register access protection all registers with write-access are optionally write-pr otected by the peripheral access controller (pac). write-protection is denoted by the write-protected property in the register description. when the cpu is halted in debug mode, all wr ite-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 21.5.9 analog connections analog functions are connected directly between the analog blocks and the i/o pads using analog buses. however, selecting an analog peripheral function for a given pin will disable the corresponding digital features of the pad. 21.5.10 cpu local bus the cpu local bus (iobus) is an interface that connects the cpu directly to the port. it is a single-cycle bus interface, and does not support wait states. it supports byte, half word and word sizes.
283 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the cpu accesses the port module through the iobus w hen it performs read or write from address 0x60000000. the port register map is equivalent to the one described in the register description section. this bus is generally used for low latency. the data direction (dir - refer to dir ) and data output value (out - refer to out ) registers can be read, written, set, cleared or toggled us ing this bus, and the data input value (in - refer to in ) registers can be read. since the iobus cannot wait for in register resynch ronization, the control register (ctrl - refer to ctrl ) must be configured to enable continuous sampling of all pins that will need to be read via the iobus to prevent stale data from being read. 21.6 functional description figure 21-2. overview of the port 21.6.1 principle of operation the i/o pins of the device are controlled by reads and writes of the port peripheral registers. for each port pin, a corresponding bit in the data direction (dir - refer to dir ) and data output value (out - refer to out ) registers are used to enable that pin as an output and to define the output state. the direction of each pin in a port bundle is configured via the dir register. if a bit in dir is written to one, the corresponding pin is configured as an output pin. if a bit in di r is written to zero, the corresponding pin is configured as an input pin. when the direction is set as output, the corresponding bit in the out register is used to set the level of the pin. if bit y of out is written to one, pin y is driven high. if bit y of out is written to zero, pin y is driven low. additional pin configuration can be set by writi ng to the pin configuration (pincfgy - refer to pincfgy ) registers. the data input value bit (in - refer to in ) is used to read the port pin with resynchronization to the port clock. by default, these input synchronizers are clocked only when an input value read is requested in order to reduce power pulleny outy diry ineny portx pady 3.3v inen oe out pullen pady pull resistor pg ng input to other modules analog input/output in iny apb bus synchronizer port_mux ... ...
284 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 consumption. input value can always be read, whether the pin is configured as input or output, except if digital input is disabled by writing a zero to the inen bit in the pin configuration registers (pincfgy). the port also allows peripheral functions to be connected to individual i/o pins by writing a one to the corresponding pmuxen bit in the pincfgy registers and by writing the ch osen selection to the peripheral multiplexing registers (pmuxn - refer to pmuxn ) for that pin. this will override the connection between the port and that i/o pin, and connect the selected peripheral line bundle to the pad instead of the port line bundle. each group of up to 32 pins is controlled by a set of registers, as described in figure 21-3 . this set of registers is duplicated for each group of pins, with increasing base addresses. figure 21-3. overview of the peripheral functions multiplexing 21.6.2 basic operation 21.6.2.1 initialization after reset, all standard-function device i/o pads are connected to the port with outputs tri-stated and input buffers disabled, even if no clocks are running. specific pins, such as the ones used for connection to a debugger, may be configured differently, as required by their special function. 21.6.3 basic operation each i/o pin y can be configured and accessed by reading or writing port registers. because port registers are grouped into sets of registers for each group of up to 32 pins, the base address of the register set for pin y is at byte address port + (y / 32) * 0x80. (y / 32) will be used as the index within that register set. to use pin y as an output, configure it as output by writing the (y / 32) bit in the dir register to one. to avoid disturbing the configuration of other pins in that group, this can also be done by writing the (y / 32) bit in the dirset register to one. the desired output value can be set by writing the (y / 32) bit to that value in register out. similarly, writing an outset bit to one will set the corres ponding bit in the out register to one, while writing an outclr bit to one will set it to zero, and writing an outtgl bit to one will toggle that bit in out. to use pin y as an input, configure it as input by writing the (y / 32) bit in the dir register to zero. to avoid disturbing th e configuration of other pins in that group, this can also be done by writing the (y / 32) bit in dirclr register to one. the port y pincfg port y periph line 0 port bit y pmuxen data+config periph line 1 periph line 15 port y pmux[3:0] port y pmux select portmux port y line bundle pad y pad y peripheral line bundles to be muxed to pad y port y peripheral mux enable 15 1 0 0 1 line bundle
285 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 desired input value can be read from the (y / 32) bit in register in as soon as the inen bit in the pin configuration register (pincfgy) is written to one. refer to ?i/o multiplexing and considerations? on page 11 for details on pin configuration. by default, the input synchronizer is clocked only when an in put read is requested, which will delay the read operation by two clk_port cycles. to remove that delay, the input synchronizers for each group of eight pins can be configured to be always active, but this comes at the expense of higher power consumption. this is controlled by writing a one to the corresponding samplingn bit group of the ct rl register, where n = (y / 32) / 8. to use pin y as one of the available peripheral functions for that pin, configure it by writing a one to the corresponding pmuxen bit of the pincfgy register. the pincfgy register for pin y is at byte offset (pincfg0 + (y / 32)). the peripheral function can be selected by writing to th e pmuxo or pmuxe bit group in the pmuxn register. the pmuxo/pmuxe bit group is at byte offset (pmux0 + (y / 32) / 2), in bits 3:0 if y is even and in bits 7:4 if y is odd. the chosen peripheral must also be configured and enabled. 21.6.4 i/o pin configuration the pin configuration register (pincfgy) is used for additional i/o pin configuration. a pin can be set in a totem-pole, open-drain or pull configuration. because pull configuration is done through the pin configurati on register, all intermediate port states during switching of pin direction and pin values are avoided. the i/o pin configurations are described further in this chapter, and summarized in table 21-1 . 21.6.4.1 pin configurations summary table 21-1. pin configurations summary dir inen pullen out configuration 0 0 0 x reset or analog i/o; all digital disabled 0 0 1 0 pull-down; input disabled 0 0 1 1 pull-up; input disabled 0 1 0 x input 0 1 1 0 input with pull-down 0 1 1 1 input with pull-up 1 0 x x output; input disabled 1 1 x x output; input enabled
286 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.6.4.2 input configuration figure 21-4. i/o configuration - standard input figure 21-5. i/o configuration - input with pull note that when pull is enabled, the pu ll value is defined by the outx value. 21.6.4.3 totem-pole output when configured for totem-pole (push-pull) output, the pin is driven low or high according to the corresponding bit setting in the out register. in this configuration, there is no current limitation for sink or source other than what the pin is capabl e of. if the pin is configured for input, the pin will float if no external pull is connected. note, that enabling the output dri ver automatically disables pull. figure 21-6. i/o configuration - totem-pole output with disabled input pullen dir ou t in inen pullen i nen dir 0 1 0 pullen dir ou t in inen pullen i nen dir 11 0 pullen dir ou t in inen pullen i nen dir 0 0 1
287 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 21-7. i/o configuration - totem-pole output with enabled input figure 21-8. i/o configuration - output with pull 21.6.4.4 digital functionality disabled figure 21-9. i/o configuration - reset or analog i/o: digital output, input and pull disabled pullen dir ou t in inen pullen i nen dir 0 1 1 pullen dir ou t in inen pullen i nen dir 1 0 0 pullen dir ou t in inen pullen i nen dir 0 0 0
288 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.7 register summary the i/o pins are organized in groups with up to 32 pins. group 0 consists of the pa pins, group 1 the pb pins, etc. each group has its own set of registers. for example, the register address offset for the data direction (dir) register for group 0 (pa00 to pa31) is 0x00, while the register address offset for the dir register for group 1 (pb00 to pb31) is 0x80. offset name bit pos. 0x00 dir 7:0 dir[7:0] 0x01 15:8 dir[15:8] 0x02 23:16 dir[23:16] 0x03 31:24 dir[31:24] 0x04 dirclr 7:0 dirclr[7:0] 0x05 15:8 dirclr[15:8] 0x06 23:16 dirclr[23:16] 0x07 31:24 dirclr[31:24] 0x08 dirset 7:0 dirset[7:0] 0x09 15:8 dirset[15:8] 0x0a 23:16 dirset[23:16] 0x0b 31:24 dirset[31:24] 0x0c dirtgl 7:0 dirtgl[7:0] 0x0d 15:8 dirtgl[15:8] 0x0e 23:16 dirtgl[23:16] 0x0f 31:24 dirtgl[31:24] 0x10 out 7:0 out[7:0] 0x11 15:8 out[15:8] 0x12 23:16 out[23:16] 0x13 31:24 out[31:24] 0x14 outclr 7:0 outclr[7:0] 0x15 15:8 outclr[15:8] 0x16 23:16 outclr[23:16] 0x17 31:24 outclr[31:24] 0x18 outset 7:0 outset[7:0] 0x19 15:8 outset[15:8] 0x1a 23:16 outset[23:16] 0x1b 31:24 outset[31:24] 0x1c outtgl 7:0 outtgl[7:0] 0x1d 15:8 outtgl[15:8] 0x1e 23:16 outtgl[23:16] 0x1f 31:24 outtgl[31:24] 0x20 in 7:0 in[7:0] 0x21 15:8 in[15:8] 0x22 23:16 in[23:16] 0x23 31:24 in[31:24] 0x24 ctrl 7:0 sampling[7:0] 0x25 15:8 sampling[15:8] 0x26 23:16 sampling[23:16] 0x27 31:24 sampling[31:24]
289 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x28 wrconfig 7:0 pinmask[7:0] 0x29 15:8 pinmask[15:8] 0x2a 23:16 drvstr pullen inen pmuxen 0x2b 31:24 hwsel wrpincfg wrpmux pmux[3:0] 0x2c reserved 0x2d 0x2e 0x2f 0x30 pmux0 7:0 pmuxo[3:0] pmuxe[3:0] 0x31 pmux1 7:0 pmuxo[3:0] pmuxe[3:0] ??? 0x3e pmux14 7:0 pmuxo[3:0] pmuxe[3:0] 0x3f pmux15 7:0 pmuxo[3:0] pmuxe[3:0] 0x40 pincfg0 7:0 drvstr pullen inen pmuxen 0x41 pincfg1 7:0 drvstr pullen inen pmuxen ??? 0x5e pincfg30 7:0 drvstr pullen inen pmuxen 0x5f pincfg31 7:0 drvstr pullen inen pmuxen offset name bit pos.
290 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 282 for details.
291 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.1 data direction name: dir offset: 0x00+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? dir[31:0]: port data direction these bits set the data direction for the individual i/o pins in the port group. 0: the corresponding i/o pin in the group is configured as an input. 1: the corresponding i/o pin in the group is configured as an output. bit3130292827262524 dir[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit2322212019181716 dir[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 dir[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 dir[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
292 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.2 data direction clear this register allows the user to set one or more i/o pins as an input, without doing a read-modify-write operation. changes in this register will also be reflected in the data direction (dir), data direction toggle (dirtgl) and data direction set (dirset) registers. name: dirclr offset: 0x04+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? dirclr[31:0]: port data direction clear 0: the i/o pin direction is cleared. 1: the i/o pin direction is set. writing a zero to a bit has no effect. writing a one to a bit will clear the corresponding bit in the dir register, which configures the i/o pin as an input. bit 3130292827262524 dirclr[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 dirclr[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 dirclr[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 dirclr[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
293 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.3 data direction set this register allows the user to set one or more i/o pi ns as an output, without doing a read-modify-write operation. changes in this register will also be reflected in the data direction (dir), data direction toggle (dirtgl) and data direction clear (dirclr) registers. name: dirset offset: 0x08+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? dirset[31:0]: port data direction set 0: the i/o pin direction is cleared. 1: the i/o pin direction is set. writing a zero to a bit has no effect. writing a one to a bit will set the corresponding bit in t he dir register, which configures the i/o pin as an output. bit 3130292827262524 dirset[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 dirset[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 dirset[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 dirset[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
294 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.4 data direction toggle this register allows the user to toggle the direction of one or more i/o pins, without doing a read-modify-write operation. changes in this register will also be reflected in the data dir ection (dir), data direction set (dirset) and data direction clear (dirclr) registers. name: dirtgl offset: 0x0c+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? dirtgl[31:0]: po rt data direction toggle 0: the i/o pin direction is cleared. 1: the i/o pin direction is set. writing a zero to a bit has no effect. writing a one to a bit will toggle the corresponding bit in t he dir register, which reverses the direction of the i/o pin. bit 3130292827262524 dirtgl[31:24] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit 2322212019181716 dirtgl[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 dirtgl[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 dirtgl[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
295 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.5 data output value this register sets the data output drive value for the individual i/o pins in the port. name: out offset: 0x10+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? out[31:0]: port data output value these bits set the logical output drive level of i/o pins configured as outputs via the data direction register (dir). for pins configured as inputs via the data direction regi ster (dir) with pull enabled via the pull enable register (pullen), these bits will set the input pull direction. 0: the i/o pin output is driven low, or the input is connected to an internal pull-down. 1: the i/o pin output is driven high, or the input is connected to an internal pull-up. bit 3130292827262524 out[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 out[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 out[15:8] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit76543210 out[7:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000
296 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.6 data output value clear this register allows the user to set one or more output i/o pin drive levels low, without doing a read-modify-write operation. changes in this register will also be reflected in the data output value (out), data output value toggle (outtgl) and data output value set (outset) registers. name: outclr offset: 0x14+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? outclr[31:0]: po rt data output value clear 0: the i/o pin output is driven low. 1: the i/o pin output is driven high. writing a zero to a bit has no effect. writing a one to a bit will clear the corresponding bit in the out register, which sets the output drive level low for i/o pins configured as outputs via the data direction regi ster (dir). for pins configured as inputs via the data direction register (dir) with pull enabled via the pull enable register (pullen), these bits will set the input pull direction to an internal pull-down. bit 3130292827262524 outclr[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 outclr[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 outclr[15:8] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit76543210 outclr[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
297 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.7 data output value set this register allows the user to set one or more output i/o pin drive levels high, without doing a read-modify-write operation. changes in this register will also be reflected in the data output value (out), data output value toggle (outtgl) and data output value clear (outclr) registers. name: outset offset: 0x18+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? outset[31:0]: po rt data output value set 0: the i/o pin output is driven low. 1: the i/o pin output is driven high. writing a zero to a bit has no effect. writing a one to a bit will set the corresponding bit in the out register, which sets the output drive level high for i/o pins configured as outputs via the data direction register (dir). for pins configured as inputs via the data direc- tion register (dir) with pull enabled via the pull enable regist er (pullen), these bits will set the input pull direction to an internal pull-up. bit 3130292827262524 outset[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 outset[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 outset[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 outset[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
298 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.8 data output value toggle this register allows the user to toggle the drive level of one or more output i/o pins, without doing a read-modify-write operation. changes in this register will also be reflected in the data output value (out), data output value set (outset) and data output value clear (outclr) registers. name: outtgl offset: 0x1c+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? outtgl[31:0]: port data output value toggle 0: the i/o pin output is driven low. 1: the i/o pin output is driven high. writing a zero to a bit has no effect. writing a one to a bit will toggle the corresponding bit in t he out register, which inverts the output drive level for i/o pins configured as outputs via the data direction regi ster (dir). for pins configured as inputs via the data direction register (dir) with pull enabled via the pull enabl e register (pullen), these bits will toggle the input pull direction. bit 3130292827262524 outtgl[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 outtgl[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 outtgl[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 76543210 outtgl[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
299 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.9 data input value name: in offset: 0x20+x*0x80 [x=0..1] reset: 0x00000000 property: - z bits 31:0 ? in[31:0]: port data input value these bits are cleared when the corresponding i/o pin input sampler detects a logical low level on the input pin. these bits are set when the corresponding i/o pin input sampler detects a logical high level on the input pin. bit 3130292827262524 in[31:24] accessrrrrrrrr reset00000000 bit 2322212019181716 in[23:16] accessrrrrrrrr reset00000000 bit 151413121110 9 8 in[15:8] accessrrrrrrrr reset00000000 bit76543210 in[7:0] accessrrrrrrrr reset00000000
300 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.10 control name: ctrl offset: 0x24+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bits 31:0 ? sampling[31:0]: input sampling mode configures the input sampling functional ity of the i/o pin input samplers for pins configured as inputs via the data direction register (dir). 0: the i/o pin input synchronizer is disabled. 1: the i/o pin input synchronizer is enabled. the input samplers are enabled and disabled in sub-groups of eight. thus, if any pins within a byte request contin- uous sampling, all pins in that eight pin sub-group will be continuously sampled. bit 3130292827262524 sampling[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 2322212019181716 sampling[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit 151413121110 9 8 sampling[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 sampling[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
301 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.11 write configuration this write-only register is used to configure several pins simultaneously with the same configuration and/or peripheral multiplexing. in order to avoid the side effect of non-atomic access, 8-bit or 16-bit writes to this register will have no effect. reading th is register always returns zero. name: wrconfig offset: 0x28+x*0x80 [x=0..1] reset: 0x00000000 property: write-protected z bit 31 ? hwsel: half-word select this bit selects the half-word field of a 32-pin group to be reconfigured in the atomic write operation. 0: the lower 16 pins of the port group will be configured. 1: the upper 16 pins of the port group will be configured. this bit will always read as zero. z bit 30 ? wrpincfg: write pincfg this bit determines whether the atomic write operation will update the pin configuration register (pincfgy) or not for all pins selected by the wrco nfig.pinmask and wrco nfig.hwsel bits. 0: the pincfgy registers of the selected pins will not be updated. 1: the pincfgy registers of the selected pins will be updated. writing a zero to this bit has no effect. bit3130292827262524 hwsel wrpincfg wrpmux pmux[3:0] accessww r wwwww reset00000000 bit2322212019181716 drvstr pullen inen pmuxen accessr w r wwwww reset00000000 bit 151413121110 9 8 pinmask[15:8] accesswwwwwwww reset00000000 bit76543210 pinmask[7:0] accesswwwwwwww reset00000000
302 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a one to this bit updates the configuration of the selected pins with the written wrconfig.drvstr, wrconfig.slewlim, wrconfig.odrain, wrconfi g.pullen, wrconfig.inen, wrconfig.pmuxen and wrconfig.pinmask values. this bit will always read as zero. z bit 29 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 28 ? wrpmux: write pmux this bit determines whether the atomic write operation wi ll update the peripheral multiplexing register (pmuxn) or not for all pins selected by the wrconfig.pinmask and wrconfig.hwsel bits. 0: the pmuxn registers of the selected pins will not be updated. 1: the pmuxn registers of the selected pins will be updated. writing a zero to this bit has no effect. writing a one to this bit updates the pin multiplexer configuration of the selected pins with the written wrcon- fig.pmux value. this bit will always read as zero. z bits 27:24 ? pmux[3:0]: peripheral multiplexing these bits determine the new value written to the peripheral multiplexing register (pmuxn) for all pins selected by the wrconfig.pinmask and wrconfig.hwsel bi ts, when the wrconfig.wrpmux bit is set. these bits will always read as zero. z bit 23 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 22 ? drvstr: output dr iver strength selection this bit determines the new value written to pincfgy.drvstr for all pins selected by the wrconfig.pinmask and wrconfig.hwsel bits the wrconfig.wrpincfg bit is set. this bit will always read as zero. z bit 21:19 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 18 ? pullen: pull enable this bit determines the new value written to pincfgy.pullen for all pins selected by the wrconfig.pinmask and wrconfig.hwsel bits when the wrconfig.wrpincfg bit is set. this bit will always read as zero. z bit 17 ? inen: input enable this bit determines the new value written to pincfgy.drvstr for all pins selected by the wrconfig.pinmask and wrconfig.hwsel bits when the wrconfig.wrpincfg bit is set. this bit will always read as zero. z bit 16 ? pmuxen: peripheral multiplexer enable this bit determines the new value written to pincfgy. pmuxen for all pins selected by the wrconfig.pin- mask and wrconfig.hwsel bits when the wrconfig.wrpincfg bit is set. this bit will always read as zero. z bits 15:0 ? pinmask[15:0]: pin mask for multiple pin configuration these bits select the pins to be configured within the half-word group selected by the wrconfig.hwsel bit.
303 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0: the configuration of the corresponding i/o pin in the half-word group will be left unchanged. 1: the configuration of the corresponding i/o pin in the half-word pin group will be updated. these bits will always read as zero.
304 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.12 peripheral multiplexing n there are up to 16 peripheral multiplexing registers in each group, one for every set of two subsequent i/o lines. the n denotes the number of the set of i/o lines, while the m denotes the number of the group. name: pmuxn offset: 0x30+n*0x1+x*0x80 [n=0..15] (x=0..1) reset: 0x00 property: write-protected z bits 7:4 ? pmuxo[3:0]: peripheral multiplexing odd these bits select the peripheral function for odd-numbered pins (2*n + 1) of a port group, if the corresponding pincfgy.pmuxen bit is one. not all possible values for this selection may be valid. for more details, refer to ?i/o multiplexing and consider- ations? on page 11 . z bits 3:0 ? pmuxe[3:0]: peripheral multiplexing even these bits select the peripheral function for even-num bered pins (2*n) of a port group, if the corresponding pincfgy.pmuxen bit is one. not all possible values for this selection may be valid. for more details, refer to ?i/o multiplexing and consider- ations? on page 11 . bit76543210 pmuxo[3:0] pmuxe[3:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 value name description 0x0 a peripheral function a selected 0x1 b peripheral function b selected 0x2 c peripheral function c selected 0x3 d peripheral function d selected 0x4 e peripheral function e selected 0x5 f peripheral function f selected 0x6 g peripheral function g selected 0x7 h peripheral function h selected 0x8-0xf reserved
305 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 21.8.13 pin configuration y there are up to 32 pin configuration registers in each group, one for each i/o line. the y denotes the number of the i/o line, while the x denotes the number of the group. name: pincfgy offset: 0x40+y*0x1+x*0x80 [n=0..31] (x=0..1) reset: 0x00 property: write-protected z bit 7 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 6 ? drvstr: output driver strength selection this bit controls the output driver strength of an i/o pin configured as an output. 0: pin drive strength is set to normal drive strength. 1: pin drive strength is set to stronger drive strength. z bits 5:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? pullen: pull enable this bit enables the internal pull-up or pull-dow n resistor of an i/o pin configured as an input. 0: internal pull resistor is disabled, and the input is in a high-impedance configuration. 1: internal pull resistor is enabled, and the input is driven to a defined logic level in the absence of external input. z bit 1 ? inen: input enable this bit controls the input buffer of an i/o pin configured as either an input or output. 0: input buffer for the i/o pin is disabled, and the input value will not be sampled. 1: input buffer for the i/o pin is enabled, and the input value will be sampled when required. writing a zero to this bit disables the input buffer completely, preventing read-back of the physical pin state when the pin is configured as either an input or output. z bit 0 ? pmuxen: peripheral multiplexer enable this bit enables or disables the peripheral multiplexer sele ction set in the peripheral multiplexing register (pmuxn) to enable or disable alternative peripheral control over an i/o pin direction and output drive value. 0: the peripheral multiplexer selection is disabled, and the port registers control the direction and output drive value. 1: the peripheral multiplexer selection is enabled, and the selected peripheral controls the direction and output drive value. writing a zero to this bit allows the port to control t he pad direction via the data direction register (dir) and out- put drive value via the data output value register (out ). the peripheral multiplexer value in pmuxn is ignored. writing a one to this bit enables the peripheral selection in pmuxn to control the pad. in this configuration, the physical pin state may still be read from the data input value register (in) if pincfgy.inen is set. bit76543210 drvstr pullen inen pmuxen access r r/w r r/w r/w r/w r/w r/w reset00000000
306 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22. evsys ? event system 22.1 overview the event system (evsys) allows autonomous, low-la tency and configurable communication between peripherals. several peripherals can be configured to emit and/or respond to signals known as events. the exact condition to generate an event, or the action taken upon receiving an event, is specific to each module. peripherals that respond to events are called event users. peripherals that emit event s are called event generators. a peripheral can have one or more event generators and can have one or more event users. communication is made without cpu intervention and without consuming system resources such as bus or ram bandwidth. this reduces the load on the cpu and other system resources, compared to a traditional interrupt-based system. 22.2 features z system for direct peripheral-to- peripheral communication and signaling z 8 configurable event channels, where each channel can: z be connected to any event generator z provide a pure asynchronous, resynchronized or synchronous path z 59 event generators z 14 event users z configurable edge detector z peripherals can be event generators, event users or both z sleepwalking and interrupt for operation in low-power modes z software event generation z each event user can choose which channel to listen to
307 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.3 block diagram figure 22-1. event system block diagram 22.4 signal description not applicable. 22.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 22.5.1 i/o lines not applicable. 22.5.2 power management the evsys can be used to wake up the cpu from all sl eep modes, even if the clock used by the evsys channel and the evsys bus clock are disabled. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. in all power save modes where the clock for the evsys is stopped, the device can wake up the evsys clock. some event generators can generate an event when the system clock is stopped. the generic clock (gclk_evsys_x) for this channel will be restarted if the channel uses a syn chronized path or a resynchronized path, without waking the system from sleep. the clock remains active only as long as necessary to handle the event. after the event has been handled, the clock will be turned off and the system will remain in the original sleep mode. this is known as sleepwalking. when an asynchronous path is used, there is no need for the clock to be activated for the event to be propagated to the user. on a software reset, all registers are set to their reset values and any ongoing events are canceled. peripherals evsys channels user mux peripherals gclk generator events clock requests users events
308 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.5.3 clocks the evsys bus clock (clk_evsys_apb) can be enabled and disabled in the power manager, and the default state of clk_evsys_apb can be found in the peripheral clock masking section in ?pm ? power manager? on page 101 . each evsys channel has a dedicated generic clock (gclk_ evsys_x). these are used for detection and propagation of events for each channel. these clocks must be configured and enabled in the generic clock controller before using the evsys. refer to ?enabling a generic clock? on page 83 for details. 22.5.4 dma not applicable. 22.5.5 interrupts the interrupt request line is connected to the interrupt c ontroller. using the evsys interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 22.5.6 events not applicable. 22.5.7 debug operation when the cpu is halted in debug mode, the evsys continues normal operation. if the evsys is configured in a way that requires it to be periodically serviced by the cpu thr ough interrupts or similar, improper operation or data loss may result during debugging. 22.5.8 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following register: z interrupt flag status and clear register ( intflag ) write-protection is denoted by the write-protected property in the register description. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 22.5.9 analog connections not applicable. 22.6 functional description 22.6.1 principle of operation event users are connected to multiplexers that have all available event channels as input. the multiplexer must be configured to select one of these channels. the channels c an be configured to route signals from any event generator, but cannot be connected to multiple event generators. 22.6.2 basic operation 22.6.2.1 initialization the peripheral that is to act as event generator should be c onfigured to be able to generate events. the peripheral to act as event user should be configured to handle incoming events. when this has been done, the event system is ready to be configured. the configuration must follow this order: 1. configure the event user by performing a single 16-bit write to the user multiplexer register ( user ) with: 6.1. the channel to be connected to a user is wr itten to the channel bit group (user.channel)
309 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1.1. the user to connect the channel is written to the user bit group (user.user) 2. configure the channel by performing a single 32-bit write to the channel ( channel ) register with: 6.2. the channel to be configured is written to the channel selection bit group (channel.channel) 2.1. the path to be used is written to the path selection bit group (channel.path) 2.2. the type of edge detection to use on the channel is written to the edge selection bit group (channel.edgsel) 2.3. the event generator to be used is written to the event generator bit group (channel.evgen) 22.6.2.2 enabling, disabling and resetting the evsys is always enabled. the evsys is reset by writing a one to the software reset bit in the control register (ctrl.swrst). all registers in the evsys will be reset to their initial state. refer to the ctrl register for details. 22.6.2.3 user multiplexer setup each user multiplexer is dedicated to one event user. a user multiplexer receives all event channel outputs and must be configured to select one of these channels. the user must always be configured before the channel is configured. a full list of selectable users can be found in the user multiplexer register ( user ) description. refer to table 22-6 for details. to configure a user multiplexer, the user r egister must be written in a single 16-bit write. it is possible to read out the configuration of a user by firs t selecting the user by writing to user.user using an 8-bit write and then performing a read of the user register. figure 22-2. user mux 22.6.2.4 channel setup the channel to be used with an event user must be configured with an event generator. the path of the channel should be configured, and when using a synchronous path or resynchr onized path, the edge selection should be configured. all these configurations are available in the channel register ( channel ). user mux peripheral a peripheral b user.channel user_evt_x user_evt_y user_evt_z channel_evt_0 channel_evt_1 channel_evt_m
310 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 to configure a channel, the channel register must be written in a single 32-bit write. it is possible to read out the configuration of a channel by first selecting the channel by writing to channel.channel using a, 8-bit write, and then performing a read of the channel register. event generators the event generator is selected by writing to the event g enerator bit group in the channel register (channel.evgen). a full list of selectable generators can be found in the channel register description. refer to table 22-3 for details. the channels are not connected to any of the ev ent generators (channel.evgen = 0x00) by default. 22.6.2.5 channel path there are three different ways to propagate the event provided by an event generator: z asynchronous path z synchronous path z resynchronized path figure 22-3. channel the path is selected by writing to the path select ion bit group in the channel register (channel.path). asynchronous path when using the asynchronous path, the events are propagated from the event generator to the event user with no intervention from the event system. this means that if t he gclk_evsys_x for the channel used is inactive, the event will still be propagated to the user. events propagated in the asynchronous path cannot generate any in terrupts, and no channel status bits will indicate the state of the channel. no edge detection is available; this must be handled in the event user. when the event generator and the event user share the same generic clock, using the asynchronous path will propagate the event with the least amount of latency. channel.swevt channel m channel.evgen peripherals sleepwalking detector clock_request_m channel.path resync edge detection channel.edgsel channel_evt_m generators events sync async
311 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 synchronous path the synchronous path should be used when the event generator and the event channel share the same generic clock. if they do not share the same clock, a logic change from the event generator to the event channel might not be detected in the channel, which means that the event will not be propagated to the event user. when using the synchronous path, the channel is capable of generating interrupts. the channel status bits in the channel status register ( chstatus ) are also updated and available for use. if the generic clocks request bit in the control regist er (ctrl.gclkreq) is zero, the channel operates in sleepwalking mode and request the configured generic cl ock only when an event is to be propagated through the channel. if ctrl.gclkreq is one, the generic clock will always be on for the configured channel. resynchronized path the resynchronized path should be used when the event generator and the event channel do not share the same clock. when the resynchronized path is used, resynchronization of the event from the event generator is done in the channel. when the resynchronized path is used, the channel is capable of generating interrupts. the channel status bits in the channel status register ( chstatus ) are also updated and available for use. if the generic clocks request bit in the control regist er (ctrl.gclkreq) is zero, the channel operates in sleepwalking mode and request the configured generic cl ock only when an event is to be propagated through the channel. if ctrl.gclkreq is one, the generic clock will always be on for the configured channel. 22.6.2.6 edge detection when synchronous or resynchronized paths are used, edge detection must be used. the event system can perform edge detection in three different ways: z generate an event only on the rising edge z generate an event only on the falling edge z generate an event on rising and falling edges. edge detection is selected by writing to the edge select ion bit group in the channel register (channel.edgsel). if the generator event is a pulse, the both edges method must not be selected. use the rising edge or falling edge detection method, depending on the generator event default level. 22.6.2.7 channel status the channel status register ( chstatus ) updates the status of the channels when a synchronous or resynchronized path is in use. there are two different status bits in chstatus for each of the available channels: the chstatus.chbusyx bit is set to one if an event on the corresponding channel x has not been handled by all event users connected to that channel. the chstatus.usrrdyx bit is set to one if all event us ers connected to the corresponding channel x are ready to handle incoming events on that channel. 22.6.2.8 software event a software event can be initiated on a channel by writing a one to the software event bit in the channel register (channel.swevt) together with the channel bits (channe l.channel). this will generate a software event on the selected channel. the software event can be used for application debugging, and functions like any event generator. to use the software event, the event path must be configured to either a synchronous path or resynchronized path (channel.path = 0x0 or 0x1), edge detection must be configured to rising-edge det ection (channel.edgsel= 0x1) and the generic clock request bit must be set to one (ctrl.gclkreq=0x1). 22.6.3 interrupts the evsys has the following interrupt sources: z overrun channel x interrupt ( intflag )
312 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z event detected channel x interrupt ( intflag ) each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set register ( intenset ), and disabled by writing a one to the corresponding bit in the interrupt enable clear register ( intenclr ). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the evsys is reset. see the intflag register for details on how to clear interrupt flags. the evsys has one common interrupt request line for all the interrupt sources. the user must read the intfla g register to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 22.6.3.1 the overrun channel x interrupt the overrun channel x interrupt flag in the interrupt flag status and clear register (intflag.ovrx) is set and the optional interrupt is generated in the following two cases: z at least one of the event users on channel x is not ready when a new event occurs z an event occurs when the previous event on channel x has not yet been handled by all event users intflag.ovrx will be set when using a synchronous or resynchronized path, but not when using an asynchronous path. 22.6.3.2 the event detect ed channel x interrupt the event detected channel x interrupt flag in the interrupt flag status and clear register (intflag.evdx) is set when an event coming from the event generator configured on channel x is detected. intflag.evdx will be set when using a synchronous and resynchronized path, but not when using an asynchronous path. 22.6.4 sleep mode operation the evsys can generate interrupts to wake up the device from any sleep mode.
313 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.7 register summary offset name bit pos. 0x00 ctrl 7:0 gclkreq swrst 0x01 reserved 0x02 reserved 0x03 reserved 0x04 channel 7:0 channel[7:0] 0x05 15:8 swevt 0x06 23:16 evgen[7:0] 0x07 31:24 edgsel[1:0] path[1:0] 0x08 user 7:0 user[7:0] 0x09 15:8 channel[7:0] 0x0a reserved 0x0b reserved 0x0c chstatus 7:0 usrrdy7 usrrdy6 usrrdy5 usrrdy4 usrrdy3 usrrdy2 usrrdy1 usrrdy0 0x0d 15:8 chbusy7 chbusy6 chbusy5 chbusy4 chbusy3 chbusy2 chbusy1 chbusy0 0x0e 23:16 0x0f 31:24 0x10 intenclr 7:0 ovr7 ovr6 ovr5 ovr4 ovr3 ovr2 ovr1 ovr0 0x11 15:8 evd7 evd6 evd5 evd4 evd3 evd2 evd1 evd0 0x12 23:16 0x13 31:24 0x14 intenset 7:0 ovr7 ovr6 ovr5 ovr4 ovr3 ovr2 ovr1 ovr0 0x15 15:8 evd7 evd6 evd5 evd4 evd3 evd2 evd1 evd0 0x16 23:16 0x17 31:24 0x18 intflag 7:0 ovr7 ovr6 ovr5 ovr4 ovr3 ovr2 ovr1 ovr0 0x19 15:8 evd7 evd6 evd5 evd4 evd3 evd2 evd1 evd0 0x1a 23:16 0x1b 31:24
314 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 308 and ?pac ? peripheral access controller? on page 28 for details. 22.8.1 control name: ctrl offset: 0x00 reset: 0x00 property: write-protected z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? gclkreq: generic clock requests this bit is used to determine whether the generic clocks used for the different channels should be on all the time or only when an event needs the generic clock. events propagated through asynchronous paths will not need a generic clock. 0: generic clock is requested and turned on only if an event is detected. 1: generic clock for a channel is always on. z bits 3:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? swrst: software reset writing a zero to this bit has no effect. writing a one to this bit resets all registers in the evsys to their initial state. writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. bit76543210 gclkreq swrst access r r r r/w r r r w reset00000000
315 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.8.2 channel this register allows the user to configure the channel specif ied in the channel bit group. to write to this register, do a single 32-bit write of all the configuration and channel selection data. to read from this register, first do an 8-bit writ e to the channel.channel bit group specifying the channel configuration to be read, and then read the channel register (channel). name: channel offset: 0x04 reset: 0x00000000 property: write-protected z bits 31:28 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 27:26 ? edgsel: edge detection selection these bits set the type of edge detection to be used on the channel. these bits must be written to zero when using the asynchronous path. bit3130292827262524 edgsel[1:0] path[1:0] access r r r r r/w r/w r/w r/w reset00000000 bit2322212019181716 evgen[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 swevt accessrrrrrrrr/w reset00000000 bit76543210 channel[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
316 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 22-1. edge detection selection z bits 25:24 ? path: path selection these bits are used to choose the path to be used by the selected channel. the path choice can be limited by the channel source, see table 22-6 . table 22-2. path selection z bits 23:16 ? evgen: event generator these bits are used to choose the event generator to connect to the selected channel. value name description 0x0 no_evt_output no event output when using the resynchronized or synchronous path 0x1 rising_edge event detection only on the rising edge of the signal from the event generator 0x2 falling_edge event detection only on the falling edge of the signal from the event generator 0x3 both_edges event detection on rising and falling edges of the signal from the event generator value name description 0x0 synchronous synchronous path 0x1 resynchronized resynchronized path 0x2 asynchronous asynchronous path 0x3 - reserved table 22-3. event generator selection value event generator description 0x00 none no event generator selected 0x01 rtc cmp0 compare 0 (mode 0 and 1) or alarm 0 (mode 2) 0x02 rtc cmp1 compare 1 0x03 rtc ovf overflow 0x04 rtc per0 period 0 0x05 rtc per1 period 1 0x06 rtc per2 period 2 0x07 rtc per3 period 3 0x08 rtc per4 period 4 0x09 rtc per5 period 5 0x0a rtc per6 period 6 0x0b rtc per7 period 7 0x0c eic extint0 external interrupt 0 0x0d eic extint1 external interrupt 1
317 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x0e eic extint2 external interrupt 2 0x0f eic extint3 external interrupt 3 0x10 eic extint4 external interrupt 4 0x11 eic extint5 external interrupt 5 0x12 eic extint6 external interrupt 6 0x13 eic extint7 external interrupt 7 0x14 eic extint8 external interrupt 8 0x15 eic extint9 external interrupt 9 0x16 eic extint10 external interrupt 10 0x17 eic extint11 external interrupt 11 0x18 eic extint12 external interrupt 12 0x19 eic extint13 external interrupt 13 0x1a eic extint14 external interrupt 14 0x1b eic extint15 external interrupt 15 0x1c tc0 ovf overflow/underflow 0x1d tc0 mc0 match/capture 0 0x1e tc0 mc1 match/capture 1 0x1f tc1 ovf overflow/underflow 0x20 tc1 mc0 match/capture 0 0x21 tc1 mc1 match/capture 1 0x22 tc2 ovf overflow/underflow 0x23 tc2 mc0 match/capture 0 0x24 tc2 mc1 match/capture 1 0x25 tc3 ovf overflow/underflow 0x26 tc3 mc0 match/capture 0 0x27 tc3 mc1 match/capture 1 0x28 tc4 ovf overflow/underflow 0x29 tc4 mc0 match/capture 0 0x2a tc4 mc1 match/capture 1 0x2b tc5 ovf overflow/underflow 0x2c tc5 mc0 match/capture 0 0x2d tc5 mc1 match/capture 1 0x2e tc6 ovf overflow/underflow table 22-3. event generator selection (continued) value event generator description
318 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 15:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? swevt: software event this bit is used to insert a software event on the channel selected by the channel.channel bit group. this bit must be written together with channel.channelusing a 16-bit write. writing a zero to this bit has no effect. writing a one to this bit will trigger a software event for the corresponding channel. this bit will always return zero when read. z bits 7:0 ? channel: channel selection these bits are used to select the channel to be set up or read from. 0x2f tc6 mc0 match/capture 0 0x30 tc6 mc1 match/capture 1 0x31 tc7 ovf overflow/underflow 0x32 tc7 mc0 match/capture 0 0x33 tc7 mc1 match/capture 1 0x34 adc resrdy result ready 0x35 adc winmon window monitor 0x36 ac comp0 comparator 0 0x37 ac comp1 comparator 1 0x38 ac win window 0 0x39 dac empty data buffer empty 0x3a ptc eoc end of conversion 0x3b ptc wcomp window comparator 0x3c-0xff reserved table 22-3. event generator selection (continued) value event generator description
319 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 22-4. channel selection value channel number 0x00 0 0x01 1 0x02 2 0x03 3 0x04 4 0x05 5 0x06 6 0x07 7 0x08-0xff reserved
320 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.8.3 user multiplexer this register is used to configure a specified event user. to write to this register, do a single 16-bit write of all the configuration and event user selection data. to read from this register, first do an 8-bit write to the us er.user bit group specifying the event user configuration to be read, and then read user. name: user offset: 0x08 reset: 0x0000 property: write-protected z bits 15:8 ? channel: channel event selection these bits are used to select the channel to connect to the event user. note that to select channel n, the value (n+1) must be written to the user.channel bit group. z bits 7:0 ? user: user multiplexer selection these bits select the event user to be configured with a channel, or the event user to read the channel value from. bit151413121110 9 8 channel[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 user[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 table 22-5. channel event selection value channel number 0x00 no channel output selected 0x01 0 0x02 1 0x03 2 0x04 3 0x05 4 0x06 5 0x07 6 0x08 7 0x09-0xff reserved
321 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 22-6. user multiplexer selection user[7:0] user multiplexer description path type 0x00 tc0 asynchronous, synchronous and resynchronized paths 0x01 tc1 asynchronous, synchronous and resynchronized paths 0x02 tc2 asynchronous, synchronous and resynchronized paths 0x03 tc3 asynchronous, synchronous and resynchronized paths 0x04 tc4 asynchronous, synchronous and resynchronized paths 0x05 tc5 asynchronous, synchronous and resynchronized paths 0x06 tc6 asynchronous, synchronous and resynchronized paths 0x07 tc7 asynchronous, synchronous and resynchronized paths 0x08 adc start adc start conversion asynchronous path only 0x09 adc sync flush adc asynchronous path only 0x0a ac comp0 start comparator 0 asynchronous path only 0x0b ac comp1 start comparator 1 asynchronous path only 0x0c dac start dac start conversion asynchronous path only 0x0d ptc stconv ptc start conversion asynchronous path only 0x0e-0xff reserved reserved
322 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.8.4 channel status name: chstatus offset: 0x0c reset: 0x000000ff property: ? z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:8 ? chbusyx: channel busy x this bit is cleared when channel x is idle this bit is set if an event on channel x has not been handled by all event users connected to channel x. z bits 7:0 ? usrrdyx: user ready for channel x this bit is cleared when at least one of the event users connected to the channel is not ready. this bit is set when all event users connected to channel x are ready to handle incoming events on channel x. bit 3130292827262524 accessrrrrrrrr reset00000000 bit 2322212019181716 accessrrrrrrrr reset00000000 bit 151413121110 9 8 chbusy7 chbusy6 chbusy5 chbusy4 chbusy3 chbusy2 chbusy1 chbusy0 accessrrrrrrrr reset00000000 bit76543210 usrrdy7 usrrdy6 usrrdy5 usrrdy4 usrrdy3 usrrdy2 usrrdy1 usrrdy0 accessrrrrrrrr reset00000000
323 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.8.5 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x10 reset: 0x00000000 property: write-protected z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:8 ? evdx: event detect ed channel x interrupt enable 0: the event detected channel x interrupt is disabled. 1: the event detected channel x interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the event detected channel x interrupt enable bit, which disables the event detected channel x interrupt. z bits 7:0 ? ovrx: overrun channel x interrupt enable 0: the overrun channel x interrupt is disabled. 1: the overrun channel x interrupt is enabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 evd7 evd6 evd5 evd4 evd3 evd2 evd1 evd0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 ovr7 ovr6 ovr5 ovr4 ovr3 ovr2 ovr1 ovr0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
324 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a zero to this bit has no effect. writing a one to this bit will clear the overrun channel x interrupt enable bit, which disables the overrun channel x interrupt.
325 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.8.6 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x14 reset: 0x00000000 property: write-protected z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:8 ? evdx: event detect ed channel x interrupt enable 0: the event detected channel x interrupt is disabled. 1: the event detected channel x interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the event detected channel x interrupt enable bit, which enables the event detected channel x interrupt. z bits 7:0 ? ovrx: overrun channel x interrupt enable 0: the overrun channel x interrupt is disabled. 1: the overrun channel x interrupt is enabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 evd7 evd6 evd5 evd4 evd3 evd2 evd1 evd0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 ovr7 ovr6 ovr5 ovr4 ovr3 ovr2 ovr1 ovr0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
326 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a zero to this bit has no effect. writing a one to this bit will set the overrun channel x interrupt enable bit, which enables the overrun channel x interrupt.
327 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.8.7 interrupt flag status and clear name: intflag offset: 0x18 reset: 0x00000000 property: ? z bits 31:16 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 15:8 ? evdx: event detected channel x this flag is set on the next clk_evsys_apb cycle w hen an event is being propagated through the channel, and an interrupt request will be generated if intenclr/set.evdx is one. when the event channel path is asynchronous, the evdx interrupt flag will not be set. writing a zero to this bit has no effect. writing a one to this bit will clear the event detected channel n interrupt flag. z bits 7:0 ? ovrx: overrun channel x this flag is set on the next clk_evsys cycle after an overrun channel condition occurs, and an interrupt request will be generated if intenclr/set.ovrx is one. there are two possible overrun channel conditions: z one or more of the event users on channel x are not ready when a new event occurs z an event happens when the previous event on channel x has not yet been handled by all event users when the event channel path is asynchronous, the ovrx interrupt flag will not be set. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 accessrrrrrrrr reset00000000 bit151413121110 9 8 evd7 evd6 evd5 evd4 evd3 evd2 evd1 evd0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 ovr7 ovr6 ovr5 ovr4 ovr3 ovr2 ovr1 ovr0 access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
328 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a zero to this bit has no effect. writing a one to this bit will clear the overrun channel x interrupt flag.
329 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 23. sercom ? serial communication interface 23.1 overview the serial communication interface (sercom) can be configured to support a number of modes; i 2 c, spi and usart. once configured and enabled, all sercom resources are dedicated to the selected mode. the sercom serial engine consists of a transmitter and receiver, baud-rate generator and address matching functionality. it can be configured to use the internal generic clock or an external clock, making operation in all sleep modes possible. 23.2 features z combined interface configurable as one of the following: z i 2 c ? two-wire serial interface z smbus ? compatible. z spi ? serial peripheral interface z usart ? universal synchronous and asynchronous serial receiver and transmitter z single transmit buffer and double receive buffer z baud-rate generator z address match/mask logic z operational in all sleep modes 23.3 block diagram figure 23-1. sercom block diagram 23.4 signal description see the respective sercom mode chapters for details: z ?sercom usart ? sercom universal synchronous and asynchronous receiver and transmitter? on page 337 z ?sercom spi ? sercom serial peripheral interface? on page 362 z ?sercom i2c ? sercom inter-integrated circuit? on page 387 tx/rx data control/status mode n sercom baud/addr transmitter register interface serial engine receiver mode 0 mode 1 baud rate generator address match mode specific pad[3:0]
330 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 23.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 23.5.1 i/o lines using the sercom i/o lines requires the i/o pins to be configured using port configuration (port). refer to ?port? on page 280 for details. from figure 23-1 one can see that the sercom has four internal pads, pad[3:0]. the signals from i 2 c, spi and usart are routed through these sercom pads via a multiplexer. the configuration of the multiplexer is available from the different sercom modes. refer to t he mode specific chapters for details: z ?sercom usart ? sercom universal synchronous and asynchronous receiver and transmitter? on page 337 z ?sercom spi ? sercom serial peripheral interface? on page 362 z ?sercom i2c ? sercom inter-integrated circuit? on page 387 23.5.2 power management the sercom can operate in any sleep mode.sercom inte rrupts can be used to wake up the device from sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 23.5.3 clocks the sercom bus clock (clk_serco mx_apb) is enabled by default, and can be enabled and disabled in the power manager. refer to ?pm ? power manager? on page 101 for details. two generic clocks are used by the sercom: gclk_s ercomx_core and gclk_sercomx_slow. the core clock (gclk_sercomx_core) is required to clock the sercom while operating as a master, while the slow clock (gclk_sercomx_slow) is only required for certain functions. see specific mode chapters for details. these clocks must be configured and enabled in the generic cl ock controller (gclk) before using the sercom. refer to ?gclk ? generic clock controller? on page 79 for details. these generic clocks are asynchronous to the user interfac e clock (clk_sercomx_apb). due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 336 for further details. 23.5.4 dma not applicable. 23.5.5 interrupts the interrupt request line is connected to the interrupt cont roller. using the sercom interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 23.5.6 events not applicable. 23.5.7 debug operation when the cpu is halted in debug mode, the sercom continues normal operation. if the sercom is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. the sercom can be forced to halt operation during debugging.
331 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 23.5.8 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register (intflag) z address register (addr) z data register (data) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all write-protection is automatically disabled. refer to ?pac ? peripheral access controller? on page 28 for details. 23.5.9 analog connections not applicable. 23.6 functional description 23.6.1 principle of operation the basic structure of the sercom serial engine is shown in figure 23-2 . fields shown in capital letters are synchronous to the system clock and accessible by the cpu, wh ile fields with lowercase letters can be configured to run on the gclk_sercomx_core clock or an external clock. figure 23-2. serco m serial engine the transmitter consists of a single write buffer and a shift regi ster. the receiver consists of a two-level receive buffer and a shift register. the baud-rate generator is capable of r unning on the gclk_sercomx_core clock or an external clock. address matching logic is included for spi and i 2 c operation. transmitter baud rate generator = = selectable internal clk (gclk) ext clk receiver address match baud rate generator tx shift register rx shift register rx buffer status baud tx data addr/addrmask rx data status 1/- /2- /16
332 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 23.6.2 basic operation 23.6.2.1 initialization the sercom must be configured to the desired mode by writ ing to the operating mode bits in the control a register (ctrla.mode). refer to figure 23-1 for details. table 23-1. sercom modes for further initialization information, see the respective sercom mode chapters. 23.6.2.2 enabling, disabling and resetting the sercom is enabled by writing a one to the enable bit in the control a register (ctr la.enable). the sercom is disabled by writing a zero to ctrla.enable. the sercom is reset by writing a one to the software reset bi t in the control a register (ctrla.swrst). all registers in the sercom, except dbgctrl, will be reset to their initial state, and the sercom will be disabled. refer to the ctrla register descriptions for details. 23.6.2.3 clock generation ? baud-rate generator the baud-rate generator, as shown in figure 23-3 , is used for internal clock generation for asynchronous and synchronous communication. the generated output frequency (f baud ) is determined by the b aud register (baud) setting and the baud reference frequency (f ref ). the baud reference clock is the serial engine clock, and it can be internal or external. for asynchronous operation, the /16 (divide-by-16) output is used when transmitting and the /1 (divide-by-1) output is used when receiving. for synchronous operation the /2 (divide-by-2) output is used. this functionality is automatically configured, depending on the selected operating mode. ctrla.mode description 0x0 usart with external clock 0x1 usart with internal clock 0x2 spi in slave operation 0x3 spi in master operation 0x4 i 2 c slave operation 0x5 i 2 c master operation 0x6-0x7 reserved
333 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 23-3. baud rate generator table 23-2 contains equations for calculating the baud rate (in bi ts per second) and for calculating the baud register value for each mode of operation. for asynchronous mode, the baud register value is 16 bi ts (0 to 65,535), while for synchronous mode, the baud register value is 8 bits (0 to 255). table 23-2. baud rate equations asynchronous mode baud value selection the formula given for f baud calculates the average frequency over 65,536 f ref cycles. although the baud register can be set to any value between 0 and 65,536, the values that will change the average frequency of f baud over a single frame are more constrained. the baud register values that will affect the average frequency over a single frame lead to an integer increase in the cycles per frame (cpf) where z d represent the data bits per frame z s represent the sum of start and first stop bits, if present base period selectable internal clk (gclk) ext clk ctrla.mode[0] 0 1 0 1 0 1 0 1 f ref clock recovery tx clk rx clk ctrla.mode /2 /8 /1 /2 /16 baud rate generator operating mode condition baud rate (bits per second) baud register value calculation asynchronous synchronous 16 f f ref baud ? ? ? ? ? ? ? = 536 , 65 1 16 baud f f ref baud ? ? ? ? ? ? ? ? ? = f f ref baud baud 16 1 536 , 65 2 f f ref baud ) 1 ( 2 + = baud f f ref baud 1 2 ? = f f baud ref baud ) ( s d cpf f f baud ref + =
334 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 23-3 shows the baud register value versus baud frequency at a serial engine frequency of 48mhz. this assumes a d value of 8 bits and an s value of 2 bits (10 bits, including start and stop bits). table 23-3. baud register va lue vs. baud frequency baud register value serial engine cpf f baud at 48mhz serial engine frequency (f ref ) 0 ? 406 160 3mhz 407 ? 808 161 2.981mhz 809 ? 1205 162 2.963mhz ... 65206 31775 15.11khz 65207 31871 15.06khz 65208 31969 15.01khz
335 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 23.6.3 additional features 23.6.3.1 address match and mask the sercom address match and mask feature is capable of matching one address with a mask, two unique addresses or a range of addresses, based on the mode selected. the match uses seven or eight bits, depending on the mode. address with mask an address written to the address bits in the address r egister (addr.addr) with a mask written to the address mask bits in the address register (addr.addrm ask) will yield an address match. all bits that are masked are not included in the match. note that setting the addr.addrmask to all zeros will match a single unique address, while setting addr.addrmask to all ones will result in all addresses being accepted. figure 23-4. address with mask two unique addresses the two addresses written to addr and addrmask will cause a match. figure 23-5. two unique addresses address range the range of addresses between and including addr.addr and addr.addrmask will caus e a match. addr.addr and addr.addrmask can be set to any two addresses, with addr.addr acting as the upper limit and addr.addrmask acting as the lower limit. figure 23-6. address range 23.6.4 dma operation not applicable. rx shift register addrmask addr == match addrmask rx shift register addr == match == addrmask rx shift register addr == match
336 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 23.6.5 interrupts interrupt sources are mode-specific. see the respective sercom mode chapters for details. each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the sercom is reset. see the register description for details on how to clear interrupt flags. the sercom has one common interrupt request line for all t he interrupt sources. the user must read the intflag register to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 23.6.6 events not applicable. 23.6.7 sleep mode operation the peripheral can operate in any sleep mode where the selected serial clock is running. this clock can be external or generated by the internal baud-rate generator. the sercom interrupts can be used to wake up the device from sleep modes. refer to the different sercom mode chapters for details. 23.6.8 synchronization due to the asynchronicity between clk_sercomx_ap b and gclk_sercomx_core, some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. the synchronization ready interrupt can be used to signal when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled.
337 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24. sercom usart ? sercom universa l synchronous and asynchronous receiver and transmitter 24.1 overview the universal synchronous and asynchronous receiver and transmitter (usart) is one of the available modes in the serial communication interface (sercom). refer to ?sercom ? serial communication interface? on page 329 for details. the usart uses the sercom transmitter and receiver configured as shown in figure 24-1 . fields shown in capital letters are synchronous to the clk_sercomx_apb and accessible by the cpu, while fields with lowercase letters can be configured to run on the internal generic clock or an external clock. the transmitter consists of a single write buffer, a shift regi ster and control logic for handling different frame formats. the write buffer allows continuous data transmission without any delay between frames. the receiver consists of a two-level receive buffer and a shift register. status information for the received data is available for error checking. data and clock recovery units ensure robust synchronization and noise filtering during asynchronous data reception. 24.2 features z full-duplex operation z asynchronous (with clock reconstruction) or synchronous operation z internal or external clock source for asynchronous and synchronous operation z baud-rate generator z supports serial frames with 5, 6, 7, 8 or 9 data bits and 1 or 2 stop bits z odd or even parity generation and parity check z selectable lsb- or msb-first data transfer z buffer overflow and frame error detection z noise filtering, including false start-bit detection and digital low-pass filter z can operate in all sleep modes z operation at speeds up to half the system clock for internally generated clocks z operation at speeds up to the system clock for externally generated clocks z start-of-frame detection
338 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.3 block diagram figure 24-1. usart block diagram 24.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 24.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 24.5.1 i/o lines using the usart?s i/o lines requires the i/o pins to be configured using port configuration (port). refer to ?port? on page 280 for details. when the sercom is used in usart mode, the pins should be configured according to table 24-1 . if the receiver or transmitter is disabled, these pins can be used for other purposes. table 24-1. usart pin configuration txd rxd xck rx shift register tx data tx shift register rx buffer rx data status status baud baud rate generator internal clk (gclk) /1 - /2 - /16 signal name signal name type description pad[3:0] digital i/o general sercom pins pin pin configuration txd output rxd input xck output or input
339 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the combined configuration of port and the transmit data pinout and receive data pinout bit groups (refer to the control a register description) will define the physical position of the usart signals in table 24-1 . 24.5.2 power management the usart can continue to operate in any sleep mode w here the selected source clock is running. the usart interrupts can be used to wake up the device from sleep m odes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 24.5.3 clocks the sercom bus clock (clk_sercomx _apb, where x represents the specific sercom instance number) can be enabled and disabled in the power manager, and the default state of clk_sercomx_apb can be found in the peripheral clock masking section in ?pm ? power manager? on page 101 . a generic clock (gclk_sercomx_core) is required to clo ck the sercomx_core. this clock must be configured and enabled in the generic clock controller before using the sercomx_core. refer to ?gclk ? generic clock controller? on page 79 for details. this generic clock is asynchronous to the bus clock (clk_serco mx_apb). due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 345 for further details. 24.5.4 dma not applicable. 24.5.5 interrupts the interrupt request line is connected to the interrupt c ontroller. using the usart interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 24.5.6 events not applicable. 24.5.7 debug operation when the cpu is halted in debug mode, the usart continues normal operation. if the usart is configured in a way that requires it to be periodically serviced by the cpu thr ough interrupts or similar, improper operation or data loss may result during debugging. the usart can be forced to halt operation during debugging. refer to dbgctrl for details. 24.5.8 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register ( intflag ) z status register ( status ) z data register ( data ) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all writ e-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details.
340 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.5.9 analog connections not applicable. 24.6 functional description 24.6.1 principle of operation the usart uses three communication lines for data transfer: z rxd for receiving z txd for transmitting z xck for the transmission clock in synchronous operation usart data transfer is frame based, where a serial frame consists of: z 1 start bit z 5, 6, 7, 8 or 9 data bits z msb or lsb first z no, even or odd parity bit z 1 or 2 stop bits a frame starts with the start bit followed by one character of data bits. if enabled, the parity bit is inserted after the data bits and before the first stop bit. one frame can be directly followed by a new frame, or the communication line can return to the idle (high) state. figure 24-2 illustrates the possible frame formats. bits inside brackets are optional. figure 24-2. frame formats st start bit; always low (n) data bits; 0 to 8 p parity bit; odd or even sp stop bit; always high idle no transfers on the communication line; always high in this state 24.6.2 basic operation 24.6.2.1 initialization the following registers are enable-protected, meaning they can only be written when the usart is disabled (ctrla.enable is zero): z control a register ( ctrla ), except the enable (enable) and software reset (swrst) bits z control b register ( ctrlb ), except the receiver enable (rxe n) and transmitter enable (txen) bits z baud register ( baud ) any writes to these registers when the usart is enabled or is being enabled (ctrla.enable is one) will be discarded. writes to these registers) while the peripheral is being disabled will be completed after the disabling is complete. before the usart is enabled, it must be configured, as outlined in the following steps: z usart mode with external or internal clock must be select ed first by writing 0x0 or 0x1 to the operating mode bit group in the control a register (ctrla.mode) 1 2 3 4 [5] [6] [7] [8] 0 st (idle) sp1 [sp2] (st/idle) [p] frame
341 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z communication mode (asynchronous or synchronous) must be selected by writing to the communication mode bit in the control a register (ctrla.cmode) z sercom pad to use for the receiver must be selected by writing to the receive data pinout bit group in the control a register (ctrla.rxpo) z sercom pads to use for the transmitter and external clock must be selected by writing to the transmit data pinout bit in the control a register (ctrla.txpo) z character size must be selected by writing to the character size bit group in the control b register (ctrlb.chsize) z msb- or lsb-first data transmission must be selected by wr iting to the data order bit in the control a register (ctrla.dord) z when parity mode is to be used, even or odd parity must be selected by writing to the parity mode bit in the control b register (ctrlb.pmode) and enabled by writing 0x1 to the frame form at bit group in the control a register (ctrla.form) z number of stop bits must be selected by writing to the stop bit mode bit in the control b register (ctrlb.sbmode) z when using an internal clock, the baud register (baud) must be written to generate the desired baud rate z the transmitter and receiver can be enabled by writing ones to the receiver enable and transmitter enable bits in the control b register (ctrlb.rxen and ctrlb.txen) 24.6.2.2 enabling, disabling and resetting the usart is enabled by writing a one to the enable bit in the control a register (ctrla.ena ble). the usart is disabled by writing a zero to ctrla.enable. the usart is reset by writing a one to the software reset bit in the control a register (ctrla.swrst). all registers in the usart, except dbgctrl, will be reset to their initial state, and the usart will be disabled. refer to the ctrla register for details. 24.6.2.3 clock generation and selection for both synchronous and asynchronous modes, the clock used for shifting and sampling data can be generated internally by the sercom baud-rate generator or suppli ed externally through the xck line. synchronous mode is selected by writing a one to the communication mode bit in the control a register (ctrla.cmode) and asynchronous mode is selected by writing a zero to ctrla.cmode. the internal clock source is selected by writing 0x1 to the operation mode bit group in the control a register (ctrla.mod e) and the external clock source is selected by writing 0x0 to ctrla.mode. the sercom baud-rate generator is configured as shown in figure 24-3 . when ctrla.cmode is zero, the baud-rate generator is automatically set to asynchronous mode and the 16-bit baud register value is used. when ctrla.cmode is one, the baud-rate generator is automatically set to syn chronous mode and the eight lsbs of the baud register are used. refer to ?clock generation ? baud-rate generator? on page 332 for details on configuring the baud rate.
342 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 24-3. clock generation synchronous clock operation when synchronous mode is used, the ctrla.mode bit group c ontrols whether the transmission clock (xck line) is an input or output. the dependency between the clock edges and data sampling or data change is the same for internal and external clocks. data input on the rxd pin is sampled at the opposite xck clock edge as data is driven on the txd pin. the clock polarity bit in the control a register (ctrla.c pol) selects which xck clock edge is used for rxd sampling and which is used for txd change. as shown in figure 24-4 , when ctrla.cpol is zero, the data will be changed on the rising xck edge and sampled on the falling xck edge. if ctrla.cpol is one, the data will be changed on the falling edge of xck and sampled on the rising edge of xck. figure 24-4. synchronous mode xck timing when the clock is provided through xck (ctrla.mode is 0x0) , the shift registers operate directly on the xck clock. this means that xck is not synchronize d with the system clock and, therefore, can operate at frequencies up to the system frequency. 24.6.2.4 data register the usart transmit data register (txd ata) and usart receive data register(r xdata) share the same i/o address, referred to as the data register (data). writing the data register will update the transmit data register. reading the data register will return the contents of the receive data register. xck baud rate generator base period /2 /2 /16 /1 ctrla.cmode 0 1 1 0 tx clk rx clk 1 0 internal clk (gclk) ctrla.mode[0] /8 0 1 sample rxd / txd xck ctrla.cpol=1 sample rxd / txd xck ctrla.cpol=0 change change
343 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.6.2.5 data transmission a data transmission is initiated by loading the data register with the data to be sent. the data in txdata is moved to the shift register when the shift register is empty and ready to send a new frame. when the shift register is loaded with data, one complete frame will be transmitted. the transmit complete interrupt flag in the interrupt fl ag status and clear register (intflag.txc) is set, and the optional interrupt is generated, when the entire frame plus stop bit(s) have been shifted out and there is no new data written to the data register. the data register should only be written when the data r egister empty flag in the interrupt flag status and clear register (intflag.dre) is set, which indicates t hat the register is empty and ready for new data. disabling the transmitter disabling the transmitter will not become effective until any ongoing and pending transmissions are completed, i.e., when the transmit shift register and txdata do not contain data to be transmitted. the transmitter is disabled by writing a zero to the transmitter enable bit in the control b register (ctrlb.txen). 24.6.2.6 data reception the receiver starts data reception when a valid start bit is det ected. each bit that follows the start bit will be sampled at the baud rate or xck clock, and shifted into the receive shift register until the first stop bit of a frame is received. when the first stop bit is received and a complete serial frame is pr esent in the receive shift register, the contents of the shift register will be moved into the two-level receive buffer. the receive complete interrupt flag in the interrupt flag status and clear register (intflag.r xc) is set, and the optional interrupt is generated. a second stop bit will be ignored by the receiver. the received data can be read by reading the data register. data should not be read unless the receive complete interrupt flag is set. disabling the receiver disabling the receiver by writing a zero to the receiver enabl e bit in the control b register (ctrlb.rxen) will flush the two-level receive buffer, and data from ongoing receptions will be lost. error bits the usart receiver has three error bits . the frame error (ferr), buffer overfl ow (bufovf) and parity error (perr) bits can be read from the status (status) register. u pon error detection, the corresponding bit will be set until it is cleared by writing a one to it. these bits are also automatically cleared when the receiver is disabled. there are two methods for buffer overflow notification. when the immediate buffer overflow notification bit (ctrla.ibon) is set, status.bufovf is raised im mediately upon buffer overflow. software can then empty the receive fifo by reading rxdata until the receive complete interrupt flag (intflag.rxc) goes low. when ctrla.ibon is zero, the buffer overflow condition travel s with data through the receive fifo. after the received data is read, status.bufovf will be set along with intflag.rxc. asynchronous data reception the usart includes a clock recovery and data recovery unit for handling asynchronous data reception. the clock recovery logic is used to synchronize the incoming asynchronous serial frames at the rxd pin to the internally generated baud-rate clock. the data recovery logic samples and applies a low-pass filter to each incoming bit, thereby improving the noise immunity of the receiver. the asynchronous reception operational range depends on the accuracy of the internal baud-rate clock, the rate of the incoming frames and the frame size (in number of bits). asynchronous operational range the operational range of the receiver depends on the difference between the received bit rate and the internally generated baud rate. if the baud rate of an external transmitter is too high or too low compared to the internally generated baud rate, the receiver will not be able to synchronize the frames to the start bit. there are two possible sources for a mismatch in baud rate. the reference clock will alwa ys have some minor instability. in addition, the baud-rate generator can not always do an exact division of the reference clock frequency to get the baud
344 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 rate desired. in this case, the baud register value should be selected to give the lowest possible error. refer to ?asynchronous mode baud value selection? on page 333 for details. recommended maximum receiver baud-rate errors for vari ous character sizes are shown in the table below. table 24-2. asynchronous receiver error the recommended maximum receiver baud-rate error assume s that the receiver and transmitter equally divide the maximum total error. the following equations can be used to calculate the ratio of the incoming data rate and internal receiver baud rate: where: z dis the sum of character size and parity size (d = 5 to 10 bits) z r slow is the ratio of the slowest incoming data rate that can be accepted in relation to the receiver baud rate z r fast is the ratio of the fastest incoming data rate that can be accepted in relation to the receiver baud rate 24.6.3 additional features 24.6.3.1 parity even or odd parity can be selected for error checking by writing 0x1 to the frame format bit group in the control a register (ctrla.form). if even parity is selected by writing a zero to the parity mode bit in the control b register (ctrlb.pmode), the parity bit of the outgoing frame is set to one if the number of data bits that are one is odd (making the total number of ones even). if odd parity is selected by wr iting a one to ctrlb.pmode, the parity bit of the outgoing frame is set to one if the number of data bits that are one is even (making the total number of ones odd). when parity checking is enabled, the parity checker calculates the parity of the data bits in incoming frames and compares the result with the parity bit of the corresponding frame. if a parity error is detected, the parity error bit in the status register (status.perr) is set. 24.6.3.2 loop-back mode by configuring the receive data pinout (ctrla.rxpo) and transmit data pinout (ctrla.txpo) to use the same data pins for transmit and receive, loop-back is achieved. the l oop-back is through the pad, so the signal is also available externally. d (data bits + parity) r slow (%) r fast (%) max total error (%) recommended max rx error (%) 5 94.12 107.69 +5.88/-7.69 2.5 6 94.92 106.67 +5.08/-6.67 2.0 7 95.52 105.88 +4.48/-5.88 2.0 8 96.00 105.26 +4.00/-5.26 2.0 9 96.39 104.76 +3.61/-4.76 1.5 10 96.70 104.35 +3.30/-4.35 1.5 6 ) 1 ( 16 ) 1 ( 16 + + + = d d r slow 8 ) 1 ( 16 ) 2 ( 16 + + + = d d r fast
345 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.6.3.3 start-of-frame detection the usart start-of-frame detector can wake up the cpu when it detects a start bit. in standby sleep mode, the internal 8mhz oscillator must be selected as the gclk_sercomx_core source. when a 1-to-0 transition is detected on rxd, the 8mhz internal oscillator is powered up and the usart clock is enabled. after startup, the rest of the data frame can be received, provided that the baud rate is slow enough in relation to the 8mhz internal oscillator start-up time. refer to ?electrical characteristics? on page 563 for details. the start-up time of the 8mhz internal oscillator varies with supply voltage and temperature. the usart start-of-frame detection works both in asynch ronous and synchronous modes. it is enabled by writing a one to the start of frame detection enable bit in the control b register (ctrlb.sfde). if the receive start interrupt enable bit in the interrupt enable set register (intenset.rxs) is set, the receive start interrupt is generated immediately when a start is detected. when using start-of-frame detection without the receive start interrupt, start detection will force the 8mhz internal oscillator and usart clock active while t he frame is being received, but the cpu will not wakeup until the receive complete interrupt is generated, if enabled. 24.6.4 interrupts the usart has the following interrupt sources: z receive start z receive complete z transmit complete z data register empty each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the usart is reset. see the register description for details on how to clear interrupt flags. the usart has one common interrupt request line for all t he interrupt sources. the user must read intflag to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 24.6.5 events not applicable. 24.6.6 sleep mode operation when using internal clocking, writing the run in standby bi t in the control a register (ctrla.runstdby) to one will allow gclk_sercomx_core to be enabled in all sleep modes. any interrupt can wake up the device. when using external clocking, writing a one to ctrla.runstd by will allow the receive complete interrupt.to wake up the device. if ctrla.runstdby is zero, the inter nal clock will be disabled when any ongoing transfer is finished. a transfer complete interrupt can wake up the device. when using external clocking, this will be disconnected when any ongoing transfer is finished, and all reception will be dropped. 24.6.7 synchronization due to the asynchronicity between clk_sercomx_ap b and gclk_sercomx_core, some registers must be synchronized when accessed. a register can require: z synchronization when written
346 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in the control a register (ctrla.swrst) z enable bit in the control a register (ctrla.enable) z receiver enable bit in the co ntrol b register (ctrlb.rxen) z transmitter enable bit in the control b register (ctrlb.txen) ctrlb.rxen and ctrlb.txen behave somewhat different ly than described above. refer to ctrlb register description for details. synchronization is denoted by the write-synchronized property in the register description.
347 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.7 register summary offset name bit pos. 0x00 ctrla 7:0 runstdby mode[2:0] enable swrst 0x01 15:8 ibon 0x02 23:16 rxpo[1:0] txpo 0x03 31:24 dord cpol cmode form[3:0] 0x04 ctrlb 7:0 sbmode chsize[2:0] 0x05 15:8 pmode sfde 0x06 23:16 rxen txen 0x07 31:24 0x08 dbgctrl 7:0 dbgstop 0x09 reserved 0x0a baud 7:0 baud[7:0] 0x0b 15:8 baud[15:8] 0x0c intenclr 7:0 rxs rxc txc dre 0x0d intenset 7:0 rxs rxc txc dre 0x0e intflag 7:0 rxs rxc txc dre 0x0f reserved 0x10 status 7:0 bufovf ferr perr 0x11 15:8 syncbusy 0x12 reserved 0x13 reserved 0x14 reserved 0x15 reserved 0x16 reserved 0x17 reserved 0x18 data 7:0 data[7:0] 0x19 15:8 data[8] 0x1a reserved 0x1b reserved 0x1c reserved 0x1d reserved 0x1e reserved 0x1f reserved
348 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 339 for details. some registers require synchronization when read and/or written. synchronization is denoted by the synchronized property in each individual register description. refer to ?synchronization? on page 345 for details. some registers are enable-protected, meaning they can only be written when the usart is disabled. enable-protection is denoted by the enable-protected property in each individual register description. 24.8.1 control a name: ctrla offset: 0x00 reset: 0x00000000 property: enable-protected, write-protected, write-synchronized z bit 31 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. bit3130292827262524 dord cpol cmode form[3:0] access r r/w r/w r/w r/w r/w r/w r/w reset00000000 bit2322212019181716 rxpo[1:0] txpo access r r r/w r/w r r r r/w reset00000000 bit151413121110 9 8 ibon accessrrrrrrrr reset00000000 bit76543210 runstdby mode[2:0] enable swrst access r/w r r r/w r/w r/w r/w r/w reset00000000
349 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 30 ? dord: data order this bit indicates the data order when a character is shifted out from the data register. 0: msb is transmitted first. 1: lsb is transmitted first. this bit is not synchronized. z bit 29 ? cpol: clock polarity this bit indicates the relationship between data output change and data input sampling in synchronous mode. this bit is not synchronized. table 24-3. clock polarity z bit 28 ? cmode: communication mode this bit indicates asynchronous or synchronous communication. 0: asynchronous communication. 1: synchronous communication. this bit is not synchronized. z bits 27:24 ? form[3:0]: frame format these bits define the frame format. these bits are not synchronized. table 24-4. frame format z bits 23:22 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 21:20 ? rxpo[1:0]: receive data pinout these bits define the receive data (rxd) pin configuration. these bits are not synchronized. cpol txd change rxd sample 0x0 rising xck edge falling xck edge 0x1 falling xck edge rising xck edge form[3:0] description 0x0 usart frame 0x1 usart frame with parity 0x2-0xf reserved
350 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 19:17 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 16 ? txpo: transmit data pinout this bit defines the transmit data (txd) and xck pin configurations. this bit is not synchronized. table 24-6. transmit data pinout z bits 15:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? ibon: immediate buff er overflow notification this bit controls when the buffer overflow status bit (s tatus.bufovf) is asserted when a buffer overflow occurs. 0: status.bufovf is asserted when it occurs in the data stream. 1: status.bufovf is asserted immediately upon buffer overflow. z bit 7 ? runstdby: run in standby this bit defines the functionality in standby sleep mode. this bit is not synchronized. table 24-7. run in standby z bits 6:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:2 ? mode: operating mode table 24-5. receive data pinout rxpo[1:0] name description 0x0 pad[0] sercom pad[0] is used for data reception 0x1 pad[1] sercom pad[1] is used for data reception 0x2 pad[2] sercom pad[2] is used for data reception 0x3 pad[3] sercom pad[3] is used for data reception txpo txd pin location xck pin location (when applicable) 0x0 pad[0] pad[1] 0x1 pad[2] pad[3] runstdby external clock internal clock 0x0 external clock is disconnected when ongoing transfer is finished. all reception is dropped. generic clock is disabled when ongoing transfer is finished. the device can wake up on receive start or transfer complete interrupt. 0x1 wake on receive start or receive complete interrupt. generic clock is enabled in all sleep modes. any interrupt can wake up the device.
351 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 these bits must be written to 0x0 or 0x1 to select the usart serial communication interface of the sercom. 0x0: usart with external clock. 0x1: usart with internal clock. these bits are not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled or being disabled. 1: the peripheral is enabled or being enabled. due to synchronization, there is delay from writing ctrla.enable until the peripheral is enabled/disabled. the value written to ctrla.enable will read back immediat ely and the synchronization busy bit in the status regis- ter (status.syncbusy) will be se t. status.syncbusy is cleared when the operation is complete. this bit is not enable-protected. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the serc om, except dbgctrl, to their initial state, and the ser- com will be disabled. writing a one to ctrla.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete. this bit is not enable-protected.
352 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.2 control b name: ctrlb offset: 0x04 reset: 0x00000000 property: enable-protected, write-protected, write-synchronized z bits 31:18 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 17 ? rxen: receiver enable 0: the receiver is disabled or being enabled. 1: the receiver is enabled or will be enabled when the usart is enabled. writing a zero to this bit will disable the usart receiv er. disabling the receiver will flush the receive buffer and clear the ferr, perr and bufovf bits in the status register. writing a one to ctrlb.rxen when the usart is disabl ed will set ctrlb.rxen immediately. when the usart is enabled, ctrlb.rxen will be cleared, and status.syncb usy will be set and remain set until the receiver is enabled. when the receiver is enabled, ctrlb.rxen will read back as one. writing a one to ctrlb.rxen when the usart is enabled will set status.syncbusy, which will remain set until the receiver is enabled, and ctrlb.rxen will read back as one. this bit is not enable-protected. z bit 16 ? txen: transmitter enable 0: the transmitter is disabled or being enabled. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 rxen txen accessrrrrrrr/wr/w reset00000000 bit151413121110 9 8 pmode sfde access r r r/w r r r r/w r reset00000000 bit76543210 sbmode chsize[2:0] access r r/w r r r r/w r/w r/w reset00000000
353 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1: the transmitter is enabled or wil l be enabled when the usart is enabled. writing a zero to this bit will disable the usart transmitter. disabling the transmitter will not become effective until ongoing and pending transmissions are completed. writing a one to ctrlb.txen when the usart is disabled will set ctrlb.txen immediately. when the usart is enabled, ctrlb.txen will be cleared, and status.syncb usy will be set and remain set until the transmitter is enabled. when the transmitter is enabled, ctrlb.txen will read back as one. writing a one to ctrlb.txen when the usart is enabled will set status.syncbusy, which will remain set until the receiver is enabled, and ctrlb.txen will read back as one. this bit is not enable-protected. z bits 15:14 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 13 ? pmode: parity mode this bit selects the type of parity used when parity is enabled (ctrla.form is one). the transmitter will automat- ically generate and send the parity of the transmitted data bits within each frame. the receiver will generate a parity value for the incoming data and parity bit, compare it to the parity mode and, if a mismatch is detected, sta- tus.perr will be set. 0: even parity. 1: odd parity. this bit is not synchronized. z bit 12:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 9 ? sfde: start of frame detection enable this bit controls whether the start-of-frame detector will wake up the device when a start bit is detected on the rxd line, according to the table below. this bit is not synchronized. z bits 8:7 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 6 ? sbmode: stop bit mode this bit selects the number of stop bits transmitted. 0: one stop bit. 1: two stop bits. this bit is not synchronized. z bits 5:3 ? reserved sfde intenset.rxs intenset.rxc description 0 x x start-of-frame detection disabled. 1 0 0 reserved 1 0 1 start-of-frame detection enabled. rxcif wakes up the device from all sleep modes. 1 1 0 start-of-frame detection enabled. rxsif wa kes up the device from all sleep modes. 1 1 1 start-of-frame detection enabled. both rx cif and rxsif wake up the device from all sleep modes.
354 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? chsize[2:0]: character size these bits select the number of bits in a character. these bits are not synchronized. table 24-8. character size chsize[2:0] description 0x0 8 bits 0x1 9 bits 0x2-0x4 reserved 0x5 5 bits 0x6 6 bits 0x7 7 bits
355 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.3 debug control name: dbgctrl offset: 0x08 reset: 0x00 property: write-protected z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? dbgstop: debug stop mode this bit controls the baud-rate generator functionality when the cpu is halted by an external debugger. 0: the baud-rate generator continues normal operati on when the cpu is halted by an external debugger. 1: the baud-rate generator is halted when the cpu is halted by an external debugger. bit76543210 dbgstop accessrrrrrrrr/w reset00000000
356 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.4 baud name: baud offset: 0x0a reset: 0x0000 property: enable-protected, write-protected z bits 15:0 ? baud: baud value these bits control the clock generation, as described in the sercom baud rate section. bit151413121110 9 8 baud[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 baud[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
357 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.5 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset) . name: intenclr offset: 0x0c reset: 0x00 property: write-protected z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? rxs: receive start interrupt enable 0: receive start interrupt is disabled. 1: receive start interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the receive start interrupt enable bit, which disables the receive start interrupt. z bit 2 ? rxc: receive comp lete interrupt enable 0: receive complete interrupt is disabled. 1: receive complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the receive complete in terrupt enable bit, which disables the receive complete interrupt. z bit 1 ? txc: transmit co mplete interrupt enable 0: transmit complete interrupt is disabled. 1: transmit complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the transmit complete interrupt enable bit, which disables the receive complete interrupt. z bit 0 ? dre: data register empty interrupt enable 0: data register empty interrupt is disabled. 1: data register empty interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the data register empty interrupt enable bit, which disables the data register empty interrupt. bit76543210 rxs rxc txc dre access r r r r r/w r/w r/w r/w reset00000000
358 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.6 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x0d reset: 0x00 property: write-protected z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? rxs: receive start interrupt enable 0: receive start interrupt is disabled. 1: receive start interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the receive start interrupt enable bit, which enables the receive start interrupt. z bit 2 ? rxc: receive comp lete interrupt enable 0: receive complete interrupt is disabled. 1: receive complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the receive complete interrupt enable bit, which enables the receive complete interrupt. z bit 1? txc: transmit co mplete interrupt enable 0: transmit complete interrupt is disabled. 1: transmit complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the transmit complete interrupt enable bit, which enables the transmit complete interrupt. z bit 0 ? dre: data register empty interrupt enable 0: data register empty interrupt is disabled. 1: data register empty interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the data register empty interrupt enable bit, which enables the data register empty interrupt. bit76543210 rxs rxc txc dre access r r r r r/w r/w r/w r/w reset00000000
359 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.7 interrupt flag status and clear name: intflag offset: 0x0e reset: 0x00 property: z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? rxs: receive start this flag is cleared by writing a one to it. this flag is set when a start condition is detected on the rxd line and start-of-frame detection is enabled (ctrlb.sfde is one). writing a zero to this bit has no effect. writing a one to this bit will clear the receive start interrupt flag. z bit 2 ? rxc: receive complete this flag is cleared by reading the data regist er (data) or by disabling the receiver. this flag is set when there are unread data in data. writing a zero to this bit has no effect. writing a one to this bit has no effect. z bit 1 ? txc: transmit complete this flag is cleared by writing a one to it or by writing new data to data. this flag is set when the entire frame in the transmit sh ift register has been shifted out and there are no new data in data. writing a zero to this bit has no effect. writing a one to this bit will clear the flag. z bit 0 ? dre: data register empty this flag is cleared by writing new data to data. this flag is set when data is empty and ready to be written. writing a zero to this bit has no effect. writing a one to this bit has no effect. bit76543210 rxs rxc txc dre access r r r r r/w r r/w r reset00000000
360 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.8 status name: status offset: 0x10 reset: 0x0000 property: z bit 15 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 14:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? bufovf: buffer overflow reading this bit before reading the data register will indi cate the error status of the next character to be read. this bit is cleared by writing a one to the bit or by disabling the receiver. this bit is set when a buffer overflow condition is detected. a buffer overflow occurs when the receive buffer is full, there is a new character waiting in the receive shift register and a new start bit is detected. writing a zero to this bit has no effect. writing a one to this bit will clear it. z bit 1 ? ferr: frame error reading this bit before reading the data register will indi cate the error status of the next character to be read. this bit is cleared by writing a one to the bit or by disabling the receiver. this bit is set if the received character had a frame error, i.e., when the first stop bit is zero. writing a zero to this bit has no effect. writing a one to this bit will clear it. z bit 0 ? perr: parity error reading this bit before reading the data register will indi cate the error status of the next character to be read. this bit is cleared by writing a one to the bit or by disabling the receiver. this bit is set if parity checking is enabled (ctrla.form is one) and a parity error is detected. writing a zero to this bit has no effect. writing a one to this bit will clear it. bit151413121110 9 8 syncbusy access r/w r r r r r r r reset00000000 bit76543210 bufovf ferr perr access r r r r r r/w r/w r/w reset00000000
361 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 24.8.9 data name: data offset: 0x18 reset: 0x0000 property: - z bits 15:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 8:0 ? data[8:0]: data reading these bits will return the contents of the receive data register. the register should be read only when the receive complete interrupt flag bit in the interrupt flag status and clear register (intflag.rxc) is set. the sta- tus bits in status should be read before reading the data value in order to get any corresponding error. writing these bits will write the transmit data register. this register should be written only when the data register empty interrupt flag bit in the interrupt flag st atus and clear register (intflag.dre) is set. bit151413121110 9 8 data[8] accessrrrrrrrr/w reset00000000 bit76543210 data[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
362 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25. sercom spi ? sercom seri al peripheral interface 25.1 overview the serial peripheral interface (spi) is one of the avail able modes in the serial communication interface (sercom). refer to ?sercom ? serial communication interface? on page 329 for details. the spi uses the sercom transmitter and receiver configured as shown in ?full-duplex spi master slave interconnection? on page 362 . each side, master and slave, depicts a separate spi containing a shift register, a transmit buffer and two receive buffers. in addition, the spi master uses the sercom baud-rate generator, while the spi slave can use the sercom address match logic. fields shown in capital letters are synchronous to clk_sercomx_apb and accessible by the cpu, while fields with lowercase letters are synchronous to the sck clock. 25.2 features z full-duplex, four-wire interface (miso, mosi, sck, _ss) z single-buffered transmitter, double-buffered receiver z supports all four spi modes of operation z single data direction operation allows alternate function on miso or mosi pin z selectable lsb- or msb-first data transfer z master operation: z serial clock speed up to half the system clock z 8-bit clock generator z slave operation: z serial clock speed up to the system clock z optional 8-bit address match operation z operation in all sleep modes 25.3 block diagram figure 25-1. full-duplex spi master slave interconnection 25.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped to one of several pins. shift register shift register master slave miso mosi sck _ss tx data rx buffer rx data tx data rx buffer rx data == addr/addrmask baud baud rate generator address match signal name type description pad[3:0] digital i/o general sercom pins
363 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 25.5.1 i/o lines using the sercom?s i/o lines requires the i/o pins to be configured using port configuration (port). refer to ?port? on page 280 for details. when the sercom is configured for spi operation, the pins should be configured according to table 25-1 . if the receiver is disabled, the data input pin can be used for other purposes. in master mode the slave select line (_ss) is controlled by software. table 25-1. spi pin configuration the combined configuration of port and the data in/data out and data out pinout bit groups in control a register will define the physical position of the spi signals in table 25-1 . 25.5.2 power management the spi can continue to operate in any sleep mode. the spi interrupts can be used to wake up the device from sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 25.5.3 clocks the sercom bus clock (clk_sercomx _apb) can be enabled and disabled in the power manager, and the default state of clk_sercomx_apb can be found in the peripheral clock masking section in the ?pm ? power manager? on page 101 . a generic clock (gclk_sercomx_core) is required to clo ck the spi. this clock must be configured and enabled in the generic clock controller before using the spi. refer to ?gclk ? generic clock controller? on page 79 for details. this generic clock is asynchronous to the bus clock (clk_serco mx_apb). due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 370 for further details. 25.5.4 dma not applicable. 25.5.5 interrupts the interrupt request line is connected to the interrupt c ontroller. using the spi, interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 25.5.6 events not applicable. pin master spi slave spi mosi output input miso input output sck output input _ss user defined output enable input
364 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.5.7 debug operation when the cpu is halted in debug mode, the spi continues normal operation. if the spi is configured in a way that requires it to be periodically serviced by the cpu through inte rrupts or similar, improper operation or data loss may result during debugging. the spi can be forced to halt operation during debugging. refer to the debug control (dbgctrl) register for details. 25.5.8 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following registers: z interrupt flag clear and status register ( intflag ) z status register ( status ) z data register ( data ) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all writ e-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 25.5.9 analog connections not applicable. 25.6 functional description 25.6.1 principle of operation the spi is a high-speed synchronous data transfer interface. it allows fast communication between the device and peripheral devices. the spi can operate as master or slave. as master, the spi in itiates and controls all data transactions. the spi is single buffered for transmitting and double buffered for receiving. when transmitting data, the data register can be loaded with the next character to be transmitted while the current transmission is in progress. for receiving, this means that the data is transferred to the two-level receive buffer upon reception, and the receiver is ready for a new character. the spi transaction format is shown in figure 25-2 , where each transaction can contai n one or more characters. the character size is configurable, and can be either 8 or 9 bits. figure 25-2. spi transaction format the spi master must initiate a transaction by pulling low the slave select line (_ss) of the desired slave. the master and slave prepare data to be sent in their respective shift regist ers, and the master generates the serial clock on the sck line. data are always shifted from master to slave on the master output, slave input line (mosi), and from slave to master on the master input, slave output line (miso). the master si gnals the end of the transaction by pulling the _ss line high. as each character is shifted out from the master, another character is shifted in from the slave. character transaction mosi/miso _ss character 0 character 1 character 2
365 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.6.2 basic operation 25.6.2.1 initialization the following registers are enable-protected, meaning t hat they can only be written when the spi is disabled (ctrla.enable is zero): z control a register ( ctrla ), except enable (ctrla.enable) and software reset (ctrla.swrst) z control b register ( ctrlb ), except receiver enable (rxen) z baud register ( baud ) z address register ( addr ) any writes to these registers when the spi is enabled or is being enabled (ctrl.enable is one) will be discarded. writes to these registers while the spi is being disabled will be completed after the disabling is complete. enable-protection is denoted by the enable-prot ection property in the register description. before the spi is enabled, it must be configured, as outlined by the following steps: z spi mode in master or slave operation must be selected by writing 0x2 or 0x3 to the operating mode bit group in the control a register (ctrla.mode) z transfer mode must be selected by writing the clock polarity bit and the clock phase bit in the control a register (ctrla.cpol and ctrla.cpha) z transaction format must be selected by writing t he frame format bit group in the control a register (ctrla.form) z sercom pad to use for the receiver must be selected by writing the data in pinout bit in the control a register (ctrla.dipo) z sercom pads to use for the transmitter, slave select and serial clock must be selected by writing the data out pinout bit group in the control a register (ctrla.dopo) z character size must be selected by writing the characte r size bit in the control b register (ctrlb.chsize) z data direction must be selected by writing the data order bit in the control a register (ctrla.dord) z if the spi is used in master mode, the baud register (baud) must be written to generate the desired baud rate z the receiver can be enabled by writing a one to the receiv er enable bit in the control b register (ctrlb.rxen) 25.6.2.2 enabling, disabling and resetting the spi is enabled by writing a one to the enable bit in the control a register (ctrla.ena ble). the spi is disabled by writing a zero to ctrla.enable. the spi is reset by writing a one to the software reset bit in the control a register (ctrla.swrst). all registers in the spi, except dbgctrl, will be reset to their initial state, and the spi will be disabled. refer to ctrla for details. 25.6.2.3 clock generation in spi master operation (ctrla.mode is 0x3), the serial clock (sck) is generated internally using the sercom baud- rate generator. when used in spi mode, the baud-rate generator is set to synchronous mode, and the 8-bit baud register (baud) value is used to generate sck, clocking the shift register. refer to ?clock generation ? baud-rate generator? on page 332 for more details. in spi slave operation (ctrla.mode is 0x2), the clock is prov ided by an external master on the sck pin. this clock is used to directly clock the spi shift register. 25.6.2.4 data register the spi transmit data register (txdata) and spi receive data register (rxdata) share the same i/o address, referred to as the spi data register (data). writing the data register will update the transmit data register. reading the data register will return the contents of the receive data register. 25.6.2.5 spi transfer modes there are four combinations of sck phase and polarity with re spect to the serial data. the spi data transfer modes are shown in table 25-2 and figure 25-3 . sck phase is selected by the clock phase bit in the control a register
366 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 (ctrla.cpha). sck polarity is selected by the clock polarity bit in the control a register (ctrla.cpol). data bits are shifted out and latched in on opposite edges of the sck signal, ens uring sufficient time for the data signals to stabilize. table 25-2. spi transfer modes leading edge is the first clock edge in a clock cycle, while trailing edge is the second clock edge in a clock cycle. figure 25-3. spi transfer modes mode cpol cpha leading edge trailing edge 0 0 0 rising, sample falling, setup 1 0 1 rising, setup falling, sample 2 1 0 falling, sample rising, setup 3 1 1 falling, setup rising, sample bit 1 bit 6 lsb msb mode 0 sample i mosi/miso change 0 mosi pin change 0 miso pin mode 2 ss msb lsb bit 6 bit 1 bit 5 bit 2 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 msb first (dord = 0) lsb first (dord = 1) mode 1 sample i mosi/miso change 0 mosi pin change 0 miso pin mode 3 ss
367 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.6.2.6 transferring data master when configured as a master (ctrla.mode is 0x3), the _ss line can be located at any general purpose i/o pin, and must be configured as an output. when the spi is ready for a data transaction, software must pull the _ss line low. when writing a character to the data regi ster (data), the character will be transferre d to the shift register when the shift register is empty. once the contents of txdata have been trans ferred to the shift register, the data register empty flag in the interrupt flag status and clear register (intflag. dre) is set, and a new character can be written to data. as each character is shifted out from the master, another charac ter is shifted in from the slave. if the receiver is enabled (ctrla.rxen is one), the contents of the shift register will be transferred to the two-level receive buffer. the transfer takes place in the same clock cycle as the last data bit is shifted in, and the receive complete interrupt flag in the interrupt flag status and clear register (intflag.rxc) will be set. the received data can be retrieved by reading data. when the last character has been transmitted and there is no va lid data in data, the transmit complete interrupt flag in the interrupt flag status and clear register (intflag.txc) is set. when the transaction is finished, the master must indicate this to the slave by pulling the _ss line high. slave when configured as a slave (ctrla.mode is 0x2), the spi inte rface will remain inactive, with the miso line tri-stated as long as the _ss pin is pulled high. software may update the contents of data at any time, as long as the data register empty flag in the interrupt status and clear register (intflag.dre) is set. when _ss is pulled low and sck is running, the slave will sample and shift out data according to the transaction mode set. when the contents of txdata have been loaded into the shift register, intflag.dre is set, and new data can be written to data. similar to the master, the slave will rece ive one character for each character transmitted. on the same clock cycle as the last data bit of a character is received, the character will be transferred into the two-level receive buffe r. the received character can be retrieved from data when intflag.rcx is set. when the master pulls the _ss line high, the transaction is done and the transmit complete interrupt flag in the interrupt flag status and clear register (txc) is set. once data is written, it takes up to three sck clock cycles before the content of data is ready to be loaded into the shift register. when the content of data is ready to be loaded, this will happen on the next character boundary. as a consequence, the first character transferred in a spi transacti on will not be the content of data. this can be avoided by using the preloading feature. refer to ?preloading of the slave shift register? on page 368 . when transmitting several characters in one spi transaction, the data has to be written to data while there are at least three sck clock cycles left in the current character transmissi on. if this criteria is not met, then the previous character received will be transmitted. after the data register is empty, it takes three clk_sercom_apb cycles for intflag.dre to be set. 25.6.2.7 receiver error bit the spi receiver has one error bit: the buffer overflow bi t (bufovf), which can be read from the status register (status). upon error detection, the bit will be set until it is cleared by writing a one to it. the bit is also automatically cleared when the receiver is disabled. there are two methods for buffer overflow notification. when the immediate buffer overflow notification bit (ctrla.ibon) is set, status.bufovf is raised im mediately upon buffer overflow. software can then empty the receive fifo by reading rxdata until the receive complete interrupt flag (intflag.rxc) goes low. when ctrla.ibon is zero, the buffer overflow condition travel s with data through the receive fifo. after the received data is read, status.bufovf will be set alo ng with intflag.rxc, and rxdata will be zero.
368 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.6.3 additional features 25.6.3.1 address recognition when the spi is configured for slave operation (ctrla.mod e is 0x2) with address recognition (ctrla.form is 0x2), the sercom address recognition logic is enabled. when addr ess recognition is enabled, the first character in a transaction is checked for an address match. if there is a match, then the receive complete interrupt flag in the interrupt flag status and clear register (intflag.rxc) is set, the miso output is enabled and the transaction is processed. if there is no match, the transaction is ignored. if the device is in sleep mode, an address match can wake up the device in order to process the transaction. if the address does not match, then the complete transaction is ignored. if a 9-bit frame format is selected, only the lower 8 bits of the shift register are checked against the address register (addr). refer to ?address match and mask? on page 335 for further details. 25.6.3.2 preloading of the slave shift register when starting a transaction, the slave will first transmit the contents of the shift register before loading new data from data. the first character sent can be either the reset value of the shift register (if this is the first transmission since the last reset) or the last character in the previous transmission. preloading can be used to preload data to the shift register while _ss is high and eliminate sending a dummy character when starting a transaction. in order to guarantee enough set-up time before the first sck edge, enough time must be given between _ss going low and the first sck sampling edge, as shown in figure 25-4 . preloading is enabled by setting the slave data preload e nable bit in the control b register (ctrlb.ploaden). figure 25-4. timing using preloading only one data character written to data will be preloaded into the shift register while the synchronized _ss signal (see figure 25-4 ) is high. the next character written to data before _ss is pulled low will be stored in data until transfer begins. if the shift register is not preloaded, the current contents of the shift register will be shifted out. 25.6.3.3 master with several slaves if the bus consists of several spi slaves, an spi master c an use general purpose i/o pins to control the _ss line to each of the slaves on the bus, as shown in figure 25-5 . in this configuration, the single selected spi slave will drive the tri- state miso line. _ss synchronization to system domain miso to sck setup time required _ss to sck time using preloaden _ss synchronized to system domain sck
369 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 25-5. multiple slaves in parallel an alternate configuration is shown in figure 25-6 . in this configuration, all n attached slaves are connected in series. a common _ss line is provided to all slaves, enabling them simultaneously. the master must shift n characters for a complete transaction. figure 25-6. multiple slaves in series 25.6.3.4 loop-back mode by configuring the data in pinout (ctrla.dipo) and data out pinout (ctrla.dopo) to use the same data pins for transmit and receive, loop-back is achieved. the loop-back is through the pad, so the signal is also available externally. 25.6.4 interrupts the spi has the following interrupt sources: z receive complete z transmit complete z data register empty each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the spi is reset. see t he register description for details on how to clear interrupt flag s. shift register shift register mosi miso sck _ss [0] mosi miso _ss sck shift register mosi miso _ss sck spi master spi slave 0 _ss[n-1] spi slave n-1 shift register shift register mosi miso sck _ss mosi miso _ss sck shift register mosi miso _ss sck spi master spi slave 0 spi slave n-1
370 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the spi has one common interrupt request line for all the interrupt sources. the user must read intflag to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. for details on clearing interrupt flags, refer to intflag . 25.6.5 events not applicable. 25.6.6 sleep mode operation during master operation, the generic clock will continue to run in idle sleep mode. if the run in standby bit in the control a register (ctrla.r unstdby) is one, the gclk_sercom_core will also be enabled in standby sleep mode. any interrupt can wake up the device. if ctrla.runstdby is zero during master operation, glk_sercomx_core will be disabled when the ongoing transaction is finished. any interrupt can wake up the device. during slave operation, writing a one to ctrla.runstdby will allow the receive complete interrupt to wake up the device. if ctrla.runstdby is zero during sl ave operation, all reception will be dropped, including the ongoing transaction. 25.6.7 synchronization due to the asynchronicity between clk_sercomx_ap b and gclk_sercomx_core, some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in the control a register (ctrla.swrst) z enable bit in the control a register (ctrla.enable) z receiver enable bit in the co ntrol b register (ctrlb.rxen) ctrlb.rxen behaves somewhat differently than described above. refer to ctrlb for details. write-synchronization is denoted by the write-synchronized property in the register description.
371 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.7 register summary offset name bit pos. 0x00 ctrla 7:0 runstdby mode[2:0] enable swrst 0x01 15:8 ibon 0x02 23:16 dipo[1:0] dopo[1:0] 0x03 31:24 dord cpol cpha form[3:0] 0x04 ctrlb 7:0 ploaden chsize[2:0] 0x05 15:8 amode[1:0] 0x06 23:16 rxen 0x07 31:24 0x08 dbgctrl 7:0 dbgstop 0x09 reserved 0x0a baud 7:0 baud[7:0] 0x0b reserved 0x0c intenclr 7:0 rxc txc dre 0x0d intenset 7:0 rxc txc dre 0x0e intflag 7:0 rxc txc dre 0x0f reserved 0x10 status 7:0 bufovf 0x11 15:8 syncbusy 0x12 reserved 0x13 reserved 0x14 addr 7:0 addr[7:0] 0x15 15:8 0x16 23:16 addrmask[7:0] 0x17 31:24 0x18 data 7:0 data[7:0] 0x19 15:8 data[8] 0x1a reserved 0x1b reserved 0x1c reserved 0x1d reserved 0x1e reserved 0x1f reserved
372 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 364 for details. some registers require synchronization when read and/or written. write-synchronization is denoted by the write- synchronized property in each individual register description. refer to ?synchronization? on page 370 for details. some registers are enable-protected, meaning they can only be written when the usart is disabled. enable-protection is denoted by the enable-protected property in each individual register description.
373 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.1 control a name: ctrla offset: 0x00 reset: 0x00000000 property: write-protected, enable-protected, write-synchronized z bit 31 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 30 ? dord: data order this bit indicates the data order when a character is shifted out from the data register. 0: msb is transferred first. 1: lsb is transferred first. this bit is not synchronized. z bit 29 ? cpol: clock polarity in combination with the clock phase bit (cpha), this bit determines the spi transfer mode. 0: sck is low when idle. the leading edge of a clock cycle is a rising edge, while the trailing edge is a falling edge. 1: sck is high when idle. the leading edge of a clock cycle is a falling edge, while the trailing edge is a rising edge. this bit is not synchronized. z bit 28 ? cpha: clock phase in combination with the clock polarity bit (cpol), this bit determines the spi transfer mode. bit3130292827262524 dord cpol cpha form[3:0] access r r/w r/w r/w r/w r/w r/w r/w reset00000000 bit2322212019181716 dipo[1:0] dopo[1:0] access r r r/w r/w r r r/w r/w reset00000000 bit151413121110 9 8 ibon accessrrrrrrrr/w reset00000000 bit76543210 runstdby mode[2:0] enable swrst access r/w r r r/w r/w r/w r/w r/w reset00000000
374 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0: the data is sampled on a leading sck edge and changed on a trailing sck edge. 1: the data is sampled on a trailing sck edge and changed on a leading sck edge. this bit is not synchronized. table 25-3. spi transfer modes z bits 27:24 ? form[3:0]: frame format table 25-4 shows the various frame formats supported by the sp i. when a frame format with address is selected, the first byte received is checked against the addr register. table 25-4. frame format z bits 23:22 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 21:20 ? dipo[1:0]: data in pinout these bits define the data in (di) pad configurations. in master operation, di is miso. in slave operation, di is mosi. these bits are not synchronized. table 25-5. data in pinout z bits 19:18 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. mode cpol cpha leading edge trailing edge 0x0 0 0 rising, sample falling, change 0x1 0 1 rising, change falling, sample 0x2 1 0 falling, sample rising, change 0x3 1 1 falling, change rising, sample form[3:0] name description 0x0 spi spi frame 0x1 - reserved 0x2 spi_addr spi frame with address 0x3-0xf - reserved dipo[1:0] name description 0x0 pad[0] sercom pad[0] is used as data input 0x1 pad[1] sercom pad[1] is used as data input 0x2 pad[2] sercom pad[2] is used as data input 0x3 pad[3] sercom pad[3] is used as data input
375 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 17:16 ? dopo: data out pinout this bit defines the available pad configurations for data out (do) and the serial clock (sck). in slave operation, the slave select line (_ss) is controlled by dopo, while in master operation the _ss line is controlled by the port configuration. in master operation, do is mosi. in slave operation, do is miso. these bits are not synchronized. table 25-6. data out pinout z bits 15:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? ibon: immediate buff er overflow notification this bit controls when the buffer overflow status bit (s tatus.bufovf) is asserted when a buffer overflow occurs. 0: status.bufovf is asserted when it occurs in the data stream. 1: status.bufovf is asserted immediately upon buffer overflow. this bit is not synchronized. z bit 7 ? runstdby: run in standby this bit defines the functionality in standby sleep mode. these bits are not synchronized. table 25-7. run in standby configuration z bits 6:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:2 ? mode: operating mode these bits must be written to 0x2 or 0x3 to select the spi serial communication interface of the sercom. 0x2: spi slave operation 0x3: spi master operation these bits are not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled or being disabled. dopo do sck slave _ss master _ss 0x0 pad[0] pad[1] pad[2] system configuration 0x1 pad[2] pad[3] pad[1] system configuration 0x2 pad[3] pad[1] pad[2] system configuration 0x3 pad[0] pad[3] pad[1] system configuration runstdby slave master 0x0 disabled. all reception is dropped, including the ongoing transaction. generic clock is disabled when ongoing transaction is finished. all interrupts can wake up the device. 0x1 wake on receive complete interrupt. generic clock is enabled while in sleep modes. all interrupts can wake up the device.
376 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1: the peripheral is enabled or being enabled. due to synchronization, there is delay from writing ctrla.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbus y is cleared when the operation is complete. this bit is not enable-protected. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the serc om, except dbgctrl, to their initial state, and the ser- com will be disabled. writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete. this bit is not enable-protected.
377 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.2 control b name: ctrlb offset: 0x04 reset: 0x00000000 property: write-protected, enable-protected z bits 31:18 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 17 ? rxen: receiver enable 0: the receiver is disabled or being enabled. 1: the receiver is enabled or it will be enabled when spi is enabled. writing a zero to this bit will disable the spi receiver immediately. the receive buffer will be flushed, data from ongoing receptions will be lost and status.bufovf will be cleared. writing a one to ctrlb.rxen when the spi is disabl ed will set ctrlb.rxen immediately. when the spi is enabled, ctrlb.rxen will be cleared, status.syncbusy will be set and remain set until the receiver is enabled. when the receiver is enabled ctrlb.rxen will read back as one. writing a one to ctrlb.rxen when the spi is enabled will se t status.syncbusy, which will remain set until the receiver is enabled, and ctrlb.rxen will read back as one. this bit is not enable-protected. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 rxen accessrrrrrrr/wr reset00000000 bit151413121110 9 8 amode[1:0] accessr/wr/wrrrrrr reset00000000 bit76543210 ploaden chsize[2:0] access r r/w r r r r/w r/w r/w reset00000000
378 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 16 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 15:14 ? amode: address mode these bits set the slave addressing mode when the frame format (ctrla.form) with address is used. they are unused in master mode. table 25-8. address mode z bits 13:7 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 6 ? ploaden: slave data preload enable setting this bit will enable preloading of the slave shift register when there is no transfer in progress. if the _ss line is high when data is written, it will be tr ansferred immediately to the shift register. z bits 5:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? chsize[2:0]: character size table 25-9. character size amode[1:0] name description 0x0 mask addrmask is used as a mask to the addr register 0x1 2_addrs the slave responds to the two unique addresses in addr and addrmask 0x2 range the slave responds to the range of addresses between and including addr and addrmask. addr is the upper limit 0x3 reserved chsize[2:0] name description 0x0 8bit 8 bits 0x1 9bit 9 bits 0x2-0x7 reserved
379 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.3 debug control name: dbgctrl offset: 0x08 reset: 0x00 property: write-protected z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? dbgstop: debug stop mode this bit controls the functionality when the cpu is halted by an external debugger. 0: the baud-rate generator continues normal operati on when the cpu is halted by an external debugger. 1: the baud-rate generator is halted when the cpu is halted by an external debugger. bit76543210 dbgstop accessrrrrrrrr/w reset00000000
380 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.4 baud rate name: baud offset: 0x0a reset: 0x00 property: write-protected, enable-protected z bits 7:0 ? baud: baud register these bits control the clock generation, as described in the sercom ?clock generation ? baud-rate generator? on page 332 . bit76543210 baud[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
381 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.5 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset) . name: intenclr offset: 0x0c reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? rxc: receive comp lete interrupt enable 0: receive complete interrupt is disabled. 1: receive complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the receive complete in terrupt enable bit, which disables the receive complete interrupt. z bit 1 ? txc: transmit co mplete interrupt enable 0: transmit complete interrupt is disabled. 1: transmit complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the transmit complete interrupt enable bit, which disable the transmit complete interrupt. z bit 0 ? dre: data register empty interrupt enable 0: data register empty interrupt is disabled. 1: data register empty interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the data register empty interrupt enable bit, which disables the data register empty interrupt. bit76543210 rxc txc dre accessrrrrrr/wr/wr/w reset00000000
382 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.6 interrupt enable set this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr) . name: intenset offset: 0x0d reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? rxc: receive comp lete interrupt enable 0: receive complete interrupt is disabled. 1: receive complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the receive complete interrupt enable bit, which enables the receive complete interrupt. z bit 1 ? txc: transmit co mplete interrupt enable 0: transmit complete interrupt is disabled. 1: transmit complete interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the transmit complete interrupt enable bit, which enables the transmit complete interrupt. z bit 0 ? dre: data register empty interrupt enable 0: data register empty interrupt is disabled. 1: data register empty interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the data register empty interrupt enable bit, which enables the data register empty interrupt. bit76543210 rxc txc dre accessrrrrrr/wr/wr/w reset00000000
383 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.7 interrupt flag status and clear name: intflag offset: 0x0e reset: 0x00 property: - z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? rxc: receive complete this flag is cleared by reading the data (data) register or by disabling the receiver. this flag is set when there are unread data in the receive buffer. if address matching is enabled, the first data received in a transaction will be an address. writing a zero to this bit has no effect. writing a one to this bit has no effect. z bit 1 ? txc: transmit complete this flag is cleared by writing a one to it or by writing new data to data. in master mode, this flag is set when the data have been shifted out and there are no new data in data. in slave mode, this flag is set when the _ss pin is pulled high. if address matching is enabled, this flag is only set if the transaction was initiated with an address match. writing a zero to this bit has no effect. writing a one to this bit will clear the flag. z bit 0 ? dre: data register empty this flag is cleared by writing new data to data. this flag is set when data is empty and ready for new data to transmit. writing a zero to this bit has no effect. writing a one to this bit has no effect. bit76543210 rxc txc dre accessrrrrrrr/wr reset00000000
384 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.8 status name: status offset: 0x10 reset: 0x0000 property: ? z bit 15 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is in progress. z bits 14:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? bufovf: buffer overflow reading this bit before reading data will indicate the error status of the next character to be read. this bit is cleared by writing a one to the bit or by disabling the receiver. this bit is set when a buffer overflow condition is detected. an overflow condition occurs if the two-level receive buffer is full when the last bit of the incoming character is shifted into the shift register. all characters shifted into the shift registers before the overflow conditi on is eliminated by reading data will be lost. when set, the corresponding rxdata will be 0. writing a zero to this bit has no effect. writing a one to this bit will clear it. z bits 1:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit151413121110 9 8 syncbusy accessrrrrrrrr reset00000000 bit76543210 bufovf accessrrrrrr/wrr reset00000000
385 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.9 address name: addr offset: 0x14 reset: 0x00000000 property: write-protected, enable-protected z bits 31:24 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 23:16 ? addrmask[7:0]: address mask these bits hold the address mask when the transacti on format (ctrla.form) with address is used. z bits 15:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? addr[7:0]: address these bits hold the address when the transacti on format (ctrla.form) with address is used. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 addrmask[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 addr[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
386 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 25.8.10 data name: data offset: 0x18 reset: 0x0000 property: ? z bits 15:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 8:0 ? data[8:0]: data reading these bits will return the contents of the receive data buffer. the register should be read only when the receive complete interrupt flag bit in the interrupt flag status and clear register (intflag.rxc) is set. writing these bits will write the transmit data buffer. th is register should be written only when the data register empty interrupt flag bit in the interrupt flag st atus and clear register (intflag.dre) is set. bit151413121110 9 8 data[8] accessrrrrrrrr/w reset00000000 bit76543210 data[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
387 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26. sercom i 2 c ? sercom inter-integrated circuit 26.1 overview the inter-integrated circuit (i 2 c) interface is one of the available modes in the serial communication interface (sercom). refer to ?sercom ? serial communication interface? on page 329 for details. the i 2 c interface uses the sercom transmitter and receiver configured as shown in figure 26-1 . fields shown in capital letters are registers accessible by the cpu, while lowercase fields are internal to the sercom. each side, master and slave, depicts a separate i 2 c interface containing a shift register, a transmit buffer and a receive buffer. in addition, the i 2 c master uses the sercom baud-rate generator, while the i 2 c slave uses the sercom address match logic. 26.2 features z master or slave operation z philips i 2 c compatible z smbus ? compatible z 100khz and 400khz support at low system clock frequencies z physical interface includes: z slew-rate limited outputs z filtered inputs z slave operation: z operation in all sleep modes z wake-up on address match z address match in hardware for: z 7-bit unique address and/or 7-bit general call address z 7-bit address range z two unique 7-bit addresses 26.3 block diagram figure 26-1. i 2 c single-master single-slave interconnection shift register shift register master slave sda scl tx data rx data tx data rx data == addr/addrmask baud baud rate generator scl low hold 0 0 0 0
388 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. note that not all the pins are i 2 c pins. refer to table 5-1 for details on the pin type for each pin. 26.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 26.5.1 i/o lines using the sercom?s i/o lines requires the i/o pins to be configured. refer to ?port? on page 280 for details. 26.5.2 power management the i 2 c will continue to operate in any sleep mode where the selected source clock is running. i 2 c interrupts can be used to wake up the device from sleep modes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 26.5.3 clocks the sercom bus clock (clk_sercomx_apb, where i repr esents the specific sercom instance number) is enabled by default, and can be enabled and disabled in the power manager. refer to ?pm ? power manager? on page 101 for details. the sercom bus clock (clk_serco mx_apb) is enabled by default, and can be enabled and disabled in the power manager. refer to ?pm ? power manager? on page 101 for details. two generic clocks are used by the sercom (gclk_serc omx_core and gclk_sercom_slow). the core clock (gclk_sercomx_core) is required to clock the sercom while operating as a master, while the slow clock (gclk_sercom_slow) is required only for certain functions. these clocks must be configured and enabled in the generic clock controller (gclk) before using the sercom. refer to ?gclk ? generic clock controller? on page 79 for details. these generic clocks are asynchronous to the sercom bus clock (clk_sercomx_apb). due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to the ?synchronization? on page 400 section for further details. 26.5.4 dma not applicable. 26.5.5 interrupts the interrupt request line is connected to the interrupt controller. using the i 2 c interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 26.5.6 events not applicable. signal name type description pad[0] digital i/o sda pad[1] digital i/o scl pad[2] digital i/o sda_out (4-wire) pad[3] digital i/o sdc_out (4-wire)
389 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.5.7 debug operation when the cpu is halted in debug mode, the i 2 c interface continues normal operation. if the i 2 c interface is configured in a way that requires it to be periodically serviced by the cp u through interrupts or similar, improper operation or data loss may result during debugging. the i 2 c interface can be forced to halt operation during debugging. refer to the dbgctrl register for details. 26.5.8 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following registers: z interrupt flag status and clear register (intflag z status register (status) z address register (addr) z data register (data) write-protection is denoted by the write-protected property in the register description. write-protection does not apply to accesses through en external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 26.5.9 analog connections not applicable. 26.6 functional description 26.6.1 principle of operation the i 2 c interface uses two physical lines for communication: z serial data line (sda) for packet transfer z serial clock line (scl) for the bus clock a transaction starts with the start condition, followed by a 7-bit address and a direction bit (read or write) sent from the i 2 c master. the addressed i 2 c slave will then acknowledge (ack) the address, and data packet transactions can commence. every 9-bit data packet consists of 8 data bits followed by a one-bit reply indicating whether the data was acknowledged or not. in the event that a data packet is not acknowledged (nack), whether sent from the i 2 c slave or master, it will be up to the i 2 c master to either terminate the connection by issuing the stop condition, or send a repeated start if more data is to be transceived. figure 26-2 illustrates the possible transaction formats and figure 26-3 explains the legend used.
390 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 26-2. basic i 2 c transaction diagram figure 26-3. transaction diagram syntax 26.6.2 basic operation 26.6.2.1 initialization the following registers are enable-protected, meaning they can be written only when the i 2 c interface is disabled (ctrla.enable is zero): z control a register (ctrla), except enable (c trla.enable) and software reset (ctrla.swrst) z control b register (ctrlb), except acknowl edge action (ctrlb.ackact) and command (ctrlb.cmd) z baud rate register (baud) z address register (addr) while in slave operation p s address 6 ... 0 r/w ack ack 7 ... 0 data ack/nack 7 ... 0 data sda scl s a a/a r/w address data p a data address packet data packet #0 transaction data packet #1 direction "0" "1" master drives bus slave drives bus either master or slave drives bus s sr p start condition repeated start condition stop condition a a acknowledge (ack) not acknowledge (nack) r w master read master write data packet direction: "0" "1" acknowledge: bus driver: special bus conditions
391 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 any writes to these bits or registers when the i 2 c interface is enabled or is being enabled (ctrla.enable is one) will be discarded. writes to these registers while the i 2 c interface is being disabled will be completed after the disabling is complete. enable-protection is denoted by the enable-prot ection property in the register description. before the i 2 c interface is enabled, it must be configured as outlined by the following steps: i 2 c mode in master or slave operation must be selected by wr iting 0x4 or 0x5 to the operating mode bit group in the control a register (ctrla.mode) z scl low time-out can be enabled by writing to the scl low time-out bit in the control a register (ctrla.lowtout) z in master operation, the inactive bus time-out can be set in the inactive time-out bit group in the control a register (ctrla.inactout) z hold time for sda can be set in the sda hold time bit group in the control a register (ctrla.sdahold) z smart operation can be enabled by writing to the sm art mode enable bit in the control b register (ctrlb.smen) z in slave operation, the address match configuration must be set in the address mode bit group in the control b register (ctrlb.amode) z in slave operation, the addresses must be set, according to the selected address configuration, in the address and address mask bit groups in the addr ess register (addr.addr and addr.addrmask) z in master operation, the baud rate register (bau d) must be written to generate the desired baud rate 26.6.2.2 enabling, disabling and resetting the i 2 c interface is enabled by writing a one to the enable bit in the control a register (ctrla.enable). the i 2 c interface is disabled by writing a zero to ctrla.enable. the i 2 c interface is reset by writing a one to the software reset bit in the control a register (ctrla.swrst). all registers in the i 2 c interface, except dbgctrl, will be reset to their initial state, and the i 2 c interface will be disabled. refer to ctrla for details. 26.6.2.3 i 2 c bus state logic the bus state logic includes several logic blocks that continuously monitor the activity on the i 2 c bus lines in all sleep modes. the start and stop detectors and the bit counter are all essential in the process of determining the current bus state. the bus state is determined according to the state diagram shown in figure 26-4 . software can get the current bus state by reading the master bus state bits in the status register (status.busstate). the value of status.busstate in the figure is shown in binary.
392 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 26-4. bus state diagram the bus state machine is active when the i 2 c master is enabled. after the i 2 c master has been enabled, the bus state is unknown. from the unknown state, the bus state machine can be forced to enter the idle state by writing to status.busstate accordingly. however, if no action is tak en by software, the bus state will become idle if a stop condition is detected on the bus. if the inactive bus time-out is enabled, the bus state will change from unknown to idle on the occurrence of a time-out. note that after a known bus stat e is established, the bus state logic will not re-enter the unknown state from either of the other states. when the bus is idle it is ready for a new transaction . if a start condition is issued on the bus by another i 2 c master in a multimaster setup, the bus becomes busy until a stop condition is detected. the stop condition will cause the bus to re- enter the idle state. if the inactive bus time-out (smbus) is enabled, the bus state will change from busy to idle on the occurrence of a time-out. if a start condition is generated in ternally by writing the address bit group in the address register (addr.addr) while in idle state, the owner stat e is entered. if the complete transaction was performed without interference, i.e., arbitration not lost, the i 2 c master is allowed to issue a stop condition, which in turn will cause a change of the bus state back to idle. however, if a packet collision is detected when in the owner state, the arbitration is assumed lost and the bus state becomes busy until a stop condition is detected. a repeated start condition will change the bus state only if arbitration is lost while issuing a repeated start. 26.6.2.4 clock generation the master i 2 c clock (scl) frequency is determined by a number of factors. the low (t low ) and high (t _high ) times are determined by the baud rate register (baud), while the rise (t rise ) and fall (t fall ) times are determined by the bus topology. because of the wired-and logic of the bus, t fall will be considered as part of t low . likewise, t rise will be in a state between t low and t high until a high state has been detected. p + timeout reset wri te addr (s) idle (0b01) s busy (0b11) p + ti meout unknown (0b00) owner (0b10) arbitration lost command p wr i t e addr (sr ) sr
393 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 26-5. scl timing the following parameters are timed using the scl low time per iod. this comes from the master baud rate low bit group in the baud rate register (baud.ba udlow) when non-zero, or the master baud rate bit group in the baud rate register (baud.baud) when baud.baudlow is zero. z t low ? low period of scl clock z t su;sto ? set-up time for stop condition z t buf ? bus free time between stop and start conditions z t hd;sta ? hold time (repeated) start condition z t su;sta ? set-up time for repeated start condition z t high is timed using the scl high time count from baud.baud z t rise is determined by the bus impedance; for internal pull-ups. refer to ?electrical characteristics? on page 563 for details. z t fall is determined by the open-drain current limit and bus impedance; can typically be regarded as zero. refer to ?electrical characteristics? on page 563 for details. the scl frequency is given by: when baud.baudlow is zero, the baud.b aud value is used to time both scl high and scl low. in this case the following formula will give the scl frequency: when baud.baudlow is non-zero, the following formula is used to determine the scl frequency: t hd;sta t low t high t buf t rise scl sda t su;sto t su;sta ps sr t fall rise high low scl t t t f + + = 1 rise gclk gclk scl t baud f f f + + = ) 5 ( 2 rise gclk gclk scl t baudlow baud f f f + + + = 10
394 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 when baudlow is non-zero, the following formula can be used to determine the scl frequency: the following formulas can be used to determine the scl t low and t high times: 26.6.2.5 i 2 c master operation the i 2 c master is byte-oriented and interrupt based. the number of interrupts generated is kept at a minimum by automatic handling of most events. auto-triggering of operations and a special smart mode, which can be enabled by writing a one to the smart mode enable bit in the control a register (ctrla.smen), are included to reduce software driver complexity and code size. the i 2 c master operates according to the behavior diagram shown in figure 26-6 . the circles with a capital letter m followed by a number (m1, m2... etc.) indicate which node in the figure the bus logic can jump to based on software or hardware interaction. this diagram is used as reference for the description of the i 2 c master operation throughout the document. rise gclk gclk scl t baudlow baud f f f + + + = 10 gclk low f baudlow baud t 5 . + = gclk high f baud baud t 5 . + =
395 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 26-6. i 2 c master behavioral diagram transmitting address packets the i 2 c master starts a bus transaction by writing addr.addr with the i 2 c slave address and the direction bit. if the bus is busy, the i 2 c master will wait until the bus becomes idle before continuing the operation. when the bus is idle, the i 2 c master will issue a start condition on the bus. the i 2 c master will then transmit an address packet using the address written to addr.addr. after the address packet has been transmitted by the i 2 c master, one of four cases will arise, based on arbitration and transfer direction. case 1: arbitration lost or bus error during address packet transmission if arbitration was lost during transmission of the address packet, the master on bus bit in the interrupt flag register (intflag.mb) and the arbitration lost bit in the status regi ster (status.arblost) are both set. serial data output to sda is disabled, and the scl is released, which disables clock stretching. in effect the i 2 c master is no longer allowed to perform any operation on the bus until the bus is idle again. a bus error will behave similarly to the arbitration lost condition. in this case, the mb interrupt flag and master bus error bit in the status regi ster (status.buserr) are both set in addition to status.arblost. the master received not acknowledge bit in the status register (status.rxnack) will always contain the last successfully received acknowledge or not acknowledge indication. in this case, software will typically inform the application code of the condition and then clear the interrupt flag before exiting the interrupt routine. no other flags have to be clea red at this point, because all flags will be cleared automatically the next time the addr.addr register is written. case 2: address packet transmit complete ? no ack received if no i 2 c slave device responds to the address packet, then t he intflag.mb interrupt flag is set and status.rxnack is set. the clock hold is active at this point, preventing further activity on the bus. idle s busy busy p sr p m3 m3 m2 m2 m1 m1 r data address w a/a data wait for idle application s w s w sr p m3 m2 busy m4 a s w a/a a/a a/a m4 a idle idle master read interrupt + hold master write interrupt + hold s w s w s w busy r/w s w software interaction the master provides data on the bus addressed slave provides data on the bus a a r/w busy m4
396 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the missing ack response can indicate that the i 2 c slave is busy with other tasks or sleeping and, therefore, not able to respond. in this event, the next step can be either issuing a stop condition (recommended) or resending the address packet by using a repeated start condition. however, the reason for the missing acknowledge can be that an invalid i 2 c slave address has been used or that the i 2 c slave is for some reason disconnected or faulty. if using smbus logic, the slave must ack the address, and hence no action means the slave is not available on the bus. case 3: address packet transmit comple te ? write packet, master on bus set if the i 2 c master receives an acknowledge response from the i 2 c slave, intflag.mb is set and status.rxnack is cleared. the clock hold is active at this point, preventing further activity on the bus. in this case, the software implementation becomes highl y protocol dependent. three possible actions can enable the i 2 c operation to continue. the three options are: z the data transmit operation is initiated by writing the data byte to be transmitted into data.data. z transmit a new address packet by writing addr.addr. a repeated start condition will automatically be inserted before the address packet. z issue a stop condition, consequently terminating the transaction. case 4: address packet transmit comp lete ? read packet, slave on bus set if the i 2 c master receives an ack from the i 2 c slave, the i 2 c master proceeds to receive the next byte of data from the i 2 c slave. when the first data byte is received, the slave on bus bit in the interrupt flag register (intflag.sb) is set and status.rxnack is cleared. the clo ck hold is active at this point, preventing further activity on the bus. in this case, the software implementation becomes highl y protocol dependent. three possible actions can enable the i 2 c operation to continue. the three options are: z let the i 2 c master continue to read data by first acknowledging the data received. this is automatically done when reading data.data if the smart mode is enabled. z transmit a new address packet. z terminate the transaction by issuing a stop condition. an ack or nack will be automatically transmitted for t he last two alternatives if smart mode is enabled. the acknowledge action bit in the control b register (ctrlb.a ckact) determines whether ac k or nack should be sent. transmitting data packets when an address packet with direction set to write (status.dir is zero) has been successfully transmitted, intflag.mb will be set and the i 2 c master can start transmitting data by writing to data.data. the i 2 c master transmits data via the i 2 c bus while continuously monitoring for packet collisions. if a collision is detected, the i 2 c master looses arbitration and stat us.arblost is set. if the transmit was successful, the i 2 c master automatically receives an ack bit from the i 2 c slave and status.rxnack will be cl eared. intflag.mb will be set in both cases, regardless of arbitration outcome. testing status.arblost and handling the arbitration lost condition in the beginning of the i 2 c master on bus interrupt is recommended. this can be done, as there is no differ ence between handling address and data packet arbitration. status.rxnack must be checked for each data packet transmitted before the next data packet transmission can commence. the i 2 c master is not allowed to continue transmitting data packets if a nack is given from the i 2 c slave. receiving data packets when intflag.sb is set, the i 2 c master will already have received one data packet. the i 2 c master must respond by sending either an ack or nack. sending a nack might not be successfully executed as arbitration can be lost during the transmission. in this case, a loss of arbitration will cause intflag.sb to not be set on completion. instead, intflag.mb will be used to indicate a change in arbitration. h andling of lost arbitration is the same as for data bit transmission. 26.6.2.6 i 2 c slave operation the i 2 c slave is byte-oriented and interrupt-based. the number of interrupts generated is kept at a minimum by automatic handling of most events. auto triggering of oper ations and a special smart mode, which can be enabled by
397 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a 1 to the smart mode enable bit in the control a register (ctrla.smen), are included to reduce software?s complexity and code size. the i 2 c slave operates according to the behavior diagram shown in figure 26-7 . the circles with a capital s followed by a number (s1, s2... etc.) indicate which node in the figure the bus logic can jump to based on software or hardware interaction. this diagram is used as reference for the description of the i 2 c slave operation throughout the document. figure 26-7. i 2 c slave behavioral diagram receiving address packets when the i 2 c slave is properly configured, it will wait for a start condition to be detected. when a start condition is detected, the successive address packet will be received and checked by the address match logic. if the received address is not a match, the packet is rejected and the i 2 c slave waits for a new start condition. the i 2 c slave address match bit in the interrupt flag register (intflag.amatch) is set when a start condition followed by a valid address packet is detected. scl will be stretched until the i 2 c slave clears intflag.amatch. because the i 2 c slave holds the clock by forcing scl low, the software is given unlimited time to respond to the address. the direction of a transaction is determined by reading the read / write direction bit in the status register (status.dir), and the bit will be updated only when a valid address packet is received. if the transmit collision bit in the status register (status.coll) is set, this indicates that the last packet addressed to the i 2 c slave had a packet collision. a collision causes the sda and scl lines to be released without any notification to software. the next amatch interrupt is, therefore, the first i ndication of the previous packet?s collision. collisions are intended to follow the smbus address resolution protocol (arp). after the address packet has been received from the i 2 c master, one of two cases will arise based on transfer direction. case 1: address packet accepted ? read flag set the status.dir bit is one, indicating an i 2 c master read operation. the scl line is forced low, stretching the bus clock. if an ack is sent, i 2 c slave hardware will set the data ready bit in the interrupt flag register (intflag.drdy), s s3 address s2 a s1 r w data a/a data p s2 sr s3 p s2 sr s3 slave address interrupt slave data interrupt a s w s w s w s w a/a a/a a s1 s w interrupt on stop condition enabled s1 slave stop interrupt s w software interaction the master provides data on the bus addressed slave provides data on the bus
398 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 indicating data are needed for transmit. if not acknowledge is sent, the i 2 c slave will wait for a new start condition and address match. typically, software will immediately acknowledge t he address packet by sending an ack/nack bit. the i 2 c slave command ctrlb.cmd = 3 can be used for both read and write operation as the command execution is dependent on the status.dir bit. writing a one to intflag.amatch will also cause an ack/ nack to be sent corresponding to the ctrlb.ackact bit. case 2: address packet accepted ? write flag set the status.dir bit is cleared, indicating an i 2 c master write operation. the scl line is forced low, stretching the bus clock. if an ack is sent, the i 2 c slave will wait for data to be received. data, repeated start or stop can be received. if not acknowledge is sent, the i 2 c slave will wait for a new start condition and address match. typically, software will immediately acknowledge t he address packet by sending an ack/nack bit. the i 2 c slave command ctrlb.cmd = 3 can be used for both read and write operation as the command execution is dependent on status.dir. writing a one to intflag.amatch will also cause an ack/ nack to be sent corresponding to the ctrlb.ackact bit. receiving and transmitting data packets after the i 2 c slave has received an address packet, it will respond according to the direction either by waiting for the data packet to be received or by starting to send a data packet by writing to data.data. when a data packet is received or sent, intflag.drdy will be set. then, if the i 2 c slave was receiving data, it will send an acknowledge according to ctrlb.ackact. case 1: data received intflag.drdy is set, and scl is held low pending sw interaction. case 2: data sent when a byte transmission is successfully completed, the intfla g.drdy interrupt flag is set. if nack is received, the i 2 c slave must expect a stop or a repeated start to be received. the i 2 c slave must release the data line to allow the i 2 c master to generate a stop or repeated start. upon stop detection, the stop received bit in the interrupt flag register (intflag.prec) will be set and the i 2 c slave will return to the idle state. 26.6.3 additional features 26.6.3.1 smbus the i 2 c hardware incorporates hardware scl low time-out, which allows a time-out to occur if the clock line is held low too long. this time-out is driven by the gclk_sercom_ slow clock. the gclk_sercom_slow clock is used to accurately time the time-out and must be configured to used a 32khz oscillator. the i 2 c interface also allows for a smbus compatible sda hold time. 26.6.3.2 smart mode the i 2 c interface incorporates a special smart mode that simplifies application code and minimizes the user interaction needed to keep hold of the i 2 c protocol. the smart mode accomplishes this by letting the reading of data.data automatically issue an ack or nack based on the state of ctrlb.ackact. 26.6.3.3 4-wire mode setting the pin usage bit in the control a register (ctrla .pinout) for master or slave to 4-wire mode enables operation as shown in figure 26-8 . in this mode, the internal i 2 c tri-state drivers are bypassed, and an external, i 2 c - compliant tri-state driver is needed when connecting to an i 2 c bus.
399 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 26-8. i2c pad interface 26.6.3.4 quick command setting the quick command enable bit in the control b register (ctrlb.qcen) enables quick command. when quick command is enabled, the corresponding interrupt flag is set immediately after the slave acknowledges the address. at this point, the software can either issue a stop command or a repeated start by writi ng ctrlb.cmd or addr.addr. 26.6.4 interrupts the i 2 c slave has the following interrupt sources: z data ready z address match z stop received the i 2 c master has the following interrupt sources: z slave on bus z master on bus each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the i 2 c is reset. see intflag for details on how to clear interrupt flags. the i 2 c has one common interrupt request line for all the interrupt sources. the user must read intflag to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 26.6.5 sleep mode operation during i 2 c master operation, the generic clock (gclk_sercomx_core) will continue to run in idle sleep mode. if the run in standby bit in the control a register (ctrla.runst dby) is one, the glk_sercomx_core will also run in standby sleep mode. any interrupt can wake up the device. if ctrla.runstdby is zero during i 2 c master operation, the glk_sercomx _core will be disabled when an ongoing transaction is finished. any interrupt can wake up the device. during i 2 c slave operation, writing a one to ctrla.runstdby will allow the address match interrupt to wake up the device. in i 2 c slave operation, all receptions will be dropped when ctrla.runstdby is zero. scl/sda pad i2c driver scl_out/ sda_out pad pinout pinout scl_in/ sda_in scl_out/ sda_out
400 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.6.6 synchronization due to the asynchronicity between clk_sercomx_ap b and gclk_sercomx_core, some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following register needs synchronization when written: z data (data) when in smart mode the following bits need synchronization when written: z software reset bit in the control a register (ctrla.swrst) z enable bit in the control a register (ctrla.enable) z write to bus state bits in the status register (status.busstate) z address bits in the address register (addr.addr) when in master operation write-synchronization is denoted by the write-synchronized property in the register description. the following register needs synchronization when read: z data (data) when in smart mode read-synchronization is denoted by the read-synchronized property in the register description.
401 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.7 register summary table 26-1. register summary ? slave mode offset name bit pos. 0x00 ctrla 7:0 runstdby mode[2:0]=100 enable swrst 0x01 15:8 0x02 23:16 sdahold[1:0] pinout 0x03 31:24 lowtout 0x04 ctrlb 7:0 0x05 15:8 amode[1:0] smen 0x06 23:16 ackact cmd[1:0] 0x07 31:24 0x08 reserved ... reserved 0x0b reserved 0x0c intenclr 7:0 drdy amatch prec 0x0d intenset 7:0 drdy amatch prec 0x0e intflag 7:0 drdy amatch prec 0x0f reserved
402 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x10 status 7:0 clkhold lowtout sr dir rxnack coll buserr 0x11 15:8 syncbusy 0x12 reserved 0x13 reserved 0x14 addr 7:0 addr[6:0] gencen 0x15 15:8 0x16 23:16 addrmask[6:0] 0x17 31:24 0x18 data 7:0 data[7:0] 0x19 15:8 table 26-1. register summary ? slave mode (continued) offset name bit pos.
403 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 26-2. register summary ? master mode offset name bit pos 0x00 ctrla 7:0 runstdby mode[2:0]=101 enable swrst 0x01 15:8 0x02 23:16 sdahold[1:0] pinout 0x03 31:24 lowtout inactout[1:0] 0x04 ctrlb 7:0 0x05 15:8 qcen smen 0x06 23:16 ackact cmd[1:0] 0x07 31:24 0x08 dbgctrl 7:0 dbgstop 0x09 reserved 0x0a baud 7:0 baud[7:0] 0x0b 15:8 baudlow[7:0] 0x0c intenclr 7:0 sb mb 0x0d intenset 7:0 sb mb 0x0e intflag 7:0 sb mb 0x0f reserved
404 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x10 status 7:0 clkhold lowtout busstate[1:0] rxnack arblost buserr 0x11 15:8 syncbusy 0x12 reserved 0x13 reserved 0x14 addr 7:0 addr[7:0] 0x15 15:8 0x16 reserved 0x17 reserved 0x18 data 7:0 data[7:0] 0x19 15:8 table 26-2. register summary ? master mode (continued) offset name bit pos
405 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each i ndividual register description. refer to ?register access protection? on page 389 for details. some registers require synchronization when read and/or wr itten. synchronization is denoted by the write-synchronized or the read-synchronized property in each individual register description. refer to ?synchronization? on page 400 for details. some registers are enable-protected, meaning they can only be written when the i 2 c is disabled. enable-protection is denoted by the enable-protected property in each individual register description.
406 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1 i 2 c slave register description 26.8.1.1 control a name: ctrla offset: 0x00 reset: 0x00000000 property: write-protected, enable-protected, write-synchronized z bit 31 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 30 ? lowtout: scl low time-out this bit enables the scl low time-out. if scl is held low for 25ms-35ms, the slave will release its clock hold, if enabled, and reset the internal state machine. any interrupts set at the time of time-out will remain set. 0: time-out disabled. 1: time-out enabled. this bit is not synchronized. z bits 29:22 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 21:20 ? sdahold[1:0]: sda hold time these bits define the sda hold time with respect to the negative edge of scl. bit3130292827262524 lowtout accessrr/wrrrrrr reset00000000 bit2322212019181716 sdahold[1:0] pinout access r r r/w r/w r r r r/w reset00000000 bit 15 14 13 12 11 10 9 8 accessrrrrrrrr reset00000000 bit76543210 runstdby mode[2:0]=100 enable swrst access r/w r r r/w r/w r/w r/w r/w reset00000000
407 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 26-3. sda hold time these bits are not synchronized. z bits 19:17 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 16 ? pinout: pin usage this bit sets the pin usage to either two- or four-wire operation: 0: 4-wire operation disabled 1: 4-wire operation enabled this bit is not synchronized. z bits 15:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 7 ? runstdby: run in standby this bit defines the functionality in standby sleep mode. 0: disabled ? all reception is dropped. 1: wake on address match, if enabled. this bit is not synchronized. z bits 6:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:2 ? mode[2:0]: operating mode these bits must be written to 0x04 to select the i 2 c slave serial communication interface of the sercom. these bits are not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled. 1: the peripheral is enabled. due to synchronization, there is delay from writing ctrla.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. this bit is not enable-protected. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. value name description 0x0 dis disabled 0x1 75 50-100ns hold time 0x2 450 300-600ns hold time 0x3 600 400-800ns hold time
408 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a one to this bit resets all registers in the serc om, except dbgctrl, to their initial state, and the ser- com will be disabled. writing a one to ctrla.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete. this bit is not enable-protected.
409 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1.2 control b name: ctrlb offset: 0x04 reset: 0x00000000 property: write-protected, enable-protected, write-synchronized z bits 31:19 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 18 ? ackact: acknowledge action 0: send ack 1: send nack the acknowledge action (ackact) bit defines the slave' s acknowledge behavior after an address or data byte is received from the master. the acknowledge action is ex ecuted when a command is written to the cmd bits. if smart mode is enabled (ctrlb.smen is one), the acknowl edge action is performed when the data register is read. this bit is not enable-protected. z bits 17:16 ? cmd[1:0]: command writing the command bits (cmd) triggers the slave operation as defined in table 26-4 . the cmd bits are strobe bits, and always read as zero. the operation is dependent on the slave interrupt flags, intflag.drdy and int- flag.amatch, in addition to status.dir (see table 26-4 ). bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 ackact cmd[1:0] accessrrrrrr/wr/wr/w reset00000000 bit151413121110 9 8 amode[1:0] smen accessr/wr/wrrrrrr/w reset00000000 bit76543210 accessrrrrrrrr reset00000000
410 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 all interrupt flags (intflag.drdy, intflag.amatch and intflag.prec) are automatically cleared when a command is given. this bit is not enable-protected. table 26-4. command description z bits 15:14 ? amode[1:0]: address mode these bits set the addressing mode according to table 26-5 . table 26-5. address mode description note: 1. see ?sercom ? serial communication interface? on page 329 for additional information. these bits are not write-synchronized. z bits 13:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? smen: smart mode enable this bit enables smart mode. when smart mode is enabl ed, acknowledge action is sent when data.data is read. 0: smart mode is disabled. 1: smart mode is enabled. this bit is not write-synchronized. cmd[1:0] dir action 0x0 x (no action) 0x1 x (reserved) 0x2 used to complete a transaction in response to a data interrupt (drdy) 0 (master write) execute acknowledge action succeeded by waiting for any start (s/sr) condition 1 (master read) wait for any start (s/sr) condition 0x3 used in response to an address interrupt (amatch) 0 (master write) execute acknowledge action succeeded by reception of next byte 1 (master read) execute acknowledge action succeeded by slave data interrupt used in response to a data interrupt (drdy) 0 (master write) execute acknowledge action succeeded by reception of next byte 1 (master read) execute a byte read operation followed by ack/nack reception value name description 0x0 mask the slave responds to the address writt en in addr.addr masked by the value in addr.addrmask (1) . 0x1 2_addrs the slave responds to the two unique addresses in addr.addr and addr.addrmask. 0x2 range the slave responds to the range of addresses between and including addr.addr and addr.addrmask. addr.addr is the upper limit. 0x3 - reserved.
411 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 7:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read.
412 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1.3 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x0c reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? drdy: data ready interrupt enable 0: the data ready interrupt is disabled. 1: the data ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the data ready bit, which disables the data ready interrupt. z bit 1 ? amatch: address match interrupt enable 0: the address match interrupt is disabled. 1: the address match interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the address match interrupt enable bit, which disables the address match interrupt. z bit 0 ? prec: stop received interrupt enable 0: the stop received interrupt is disabled. 1: the stop received interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the stop received bit, which disables the stop received interrupt. bit76543210 drdy amatch prec accessrrrrrr/wr/wr/w reset00000000
413 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1.4 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x0d reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? drdy: data ready interrupt enable 0: the data ready interrupt is disabled. 1: the data ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the data ready bit, which enables the data ready interrupt. z bit 1 ? amatch: address match interrupt enable 0: the address match interrupt is disabled. 1: the address match interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the address match inte rrupt enable bit, which enables the address match interrupt. z bit 0 ? prec: stop received interrupt enable 0: the stop received interrupt is disabled. 1: the stop received interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the stop received bit, which enables the stop received interrupt. bit76543210 drdy amatch prec accessrrrrrr/wr/wr/w reset00000000
414 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1.5 interrupt flag status and clear name: intflag offset: 0x0e reset: 0x00 property: - z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? drdy: data ready this flag is set when a i 2 c slave byte transmission is successfully completed. the flag is cleared by hardware when either: z writing to the data register. z reading the data register with smart mode enabled. z writing a valid command to the cmd register. writing a zero to this bit has no effect. writing a one to this bit will clear the data ready interrupt flag. optionally, the flag can be cleared manually by writ- ing a one to intflag.drdy. z bit 1 ? amatch: address match this flag is set when the i 2 c slave address match logic detects that a valid address has been received. the flag is cleared by hardware when ctrl.cmd is written. writing a zero to this bit has no effect. writing a one to this bit will clear the address match interrupt flag. optionally the flag can be cleared manually by writing a one to intflag.amatch. when cleared, an ac k/nack will be sent according to ctrlb.ackact. z bit 0 ? prec: stop received this flag is set when a stop condition is detected for a transaction being processed. a stop condition detected between a bus master and another slave will not set this flag. this flag is cleared by hardware after a command is issued on the next address match. writing a zero to this bit has no effect. writing a one to this bit will clear the stop received interrupt flag. optionally, the flag can be cleared manually by writing a one to intflag.prec. bit 76543210 drdy amatch prec access rrrrrr/wr/wr/w reset 00000000
415 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1.6 status name: status offset: 0x10 reset: 0x0000 property: - z bit 15 ? syncbusy: synchronization busy this bit is set when the synchronization of registers between clock domains is started. this bit is cleared when the synchronization of registers between the clock domains is complete. z bits 14:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 7 ? clkhold: clock hold the slave clock hold bit (status.clkhold) is set when the slave is holding the scl line low, stretching the i 2 c clock. software should consider this bit a read-only status flag that is set when intflag.drdy or int- flag.amatch is set. this bit is automatically cleared when the corresponding interrupt is also cleared. z bit 6 ? lowtout: scl low time-out this bit is set if an scl low time-out occurs. this bit is cleared automatically if responding to a new st art condition with ack or nack (write 3 to ctrlb.cmd) or when intflag.amatch is cleared. 0: no scl low time-out has occurred. 1: scl low time-out has occurred. writing a zero to this bit has no effect. writing a one to this bit will clear the status. z bit 5 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 4 ? sr: repeated start when intflag.amatch is raised due to an address match, sr indicates a repeated start or start condition. 0: start condition on last address match 1: repeated start condition on last address match this flag is only valid while the intflag.amatch flag is one. bit 151413121110 9 8 syncbusy accessrrrrrrrr reset00000000 bit 76543210 clkhold lowtout sr dir rxnack coll buserr access r r/w r r r r r/w r/w reset00000000
416 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 3 ? dir: read / write direction the read/write direction (status.dir) bit stores the dire ction of the last address packet received from a master. 0: master write operation is in progress. 1: master read operation is in progress. z bit 2 ? rxnack: received not acknowledge this bit indicates whether the last data packet sent was acknowledged or not. 0: master responded with ack. 1: master responded with nack. z bit 1 ? coll: transmit collision if set, the i 2 c slave was not able to transmit a high data or nack bit, the i 2 c slave will immediately release the sda and scl lines and wait for the next packet addressed to it. this flag is intended for the smbus address resolution prot ocol (arp). a detected collision in non-arp situations indicates that there has been a protocol violation, and should be treated as a bus error. note that this status will not trigger any interrupt, and should be checked by software to verify that the data were sent correctly. this bit is cleared automatically if res ponding to an address match with an ack or a nack (writing 0x3 to ctrlb.cmd), or intflag.amatch is cleared. 0: no collision detected on last data byte sent. 1: collision detected on last data byte sent. writing a zero to this bit has no effect. writing a one to this bit will clear the status. z bit 0 ? buserr: bus error the bus error bit (status.buserr) indicates that an illegal bus condition has occurred on the bus, regardless of bus ownership. an illegal bus condition is detected if a protocol violating start, repeated start or stop is detected on the i 2 c bus lines. a start condition directly followed by a st op condition is one example of a protocol violation. if a time-out occurs during a frame, this is also cons idered a protocol violation, and will set status.buserr. this bit is cleared automatically if responding to an addr ess match with an ack or a nack (writing 0x3 to ctrlb.cmd) or intflag.amatch is cleared. 0: no bus error detected. 1: bus error detected. writing a one to this bit will clear the status. writing a zero to this bit has no effect.
417 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1.7 address name: addr offset: 0x14 reset: 0x00000000 property: write-protected, enable-protected z bits 31:24 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 23:17 ? addrmask[6:0]: address mask the addrmask bits acts as a sec ond address match register, an address mask register or the lower limit of an address range, depending on the ctrlb.amode setting. z bits 16:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:1 ? addr[6:0]: address the slave address (addr) bits contain the i 2 c slave address used by the slave address match logic to determine if a master has addressed the slave. when using 7-bit addressing, the address register (addr.addr) represents the slave address. if using 10-bit addressing, the address match logic only suppor ts hardware address recognition of the first 2 bits of a 10-bit address. if writing addr.addr = "0b1111 0xx," 'xx' r epresents bits 9 and 8 or the slave address. the next byte received is bits 7 to 0 in the 10-bit address, and this must be handled by software. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 addrmask[6:0] access r/w r/w r/w r/w r/w r/w r/w r reset00000000 bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 addr[6:0] gencen access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
418 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 when the address match logic detects a match, intflag. amatch is set and status.dir is updated to indicate whether it is a read or a write transaction. z bit 0 ? gencen: general call address enable writing a one to gencen enables general call address reco gnition. a general call address is an address of all zeroes with the direction bit written to zero (master write). 0: general call address recognition disabled. 1: general call address recognition enabled.
419 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.1.8 data name: data offset: 0x18 reset: 0x0000 property: write-synchronized, read-synchronized z bits 15:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? data[7:0]: data the slave data register i/o location (data.data) provides access to the master transmit and receive data buf- fers. reading valid data or writing data to be transmitt ed can be successfully done only when scl is held low by the slave (status.clkhold is set). an exception occurs when reading the last data byte after the stop condition has been received. accessing data.data auto-triggers i 2 c bus operations. the operation performed depends on the state of ctrlb.ackact, ctrlb.smen and the type of access (read/write). writing or reading data.data when not in smart mode does not require synchronization. bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 data[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
420 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2 i 2 c master register description 26.8.2.1 control a name: ctrla offset: 0x00 reset: 0x00000000 property: write-protected, enable-protected, write-synchronized z bit 31 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 30 ? lowtout: scl low time-out this bit enables the scl low time-out. if scl is held low for 25ms-35ms, the master will release its clock hold, if enabled, and complete the current transaction. a stop condition will automatically be transmitted. intflag.sb or intflag.mb will be set as normal, but the clock hold will be released. the status.lowtout and status.buserr status bits will be set. 0: time-out disabled. 1: time-out enabled. this bit is not synchronized. z bits 29:28 ? inactout[1:0]: inactive time-out if the inactive bus time-out is enabled and the bus is inactive for longer than the time-out setting, the bus state logic will be set to idle. an inactive bus arise when either an i 2 c master or slave is holding the scl low. the available time-outs are given in table 26-6 . bit 3130292827262524 lowtout inactout[1:0] access r r/w r/w r/w r r r r reset00000000 bit 2322212019181716 sdahold[1:0] pinout access r r r/w r/w r r r r/w reset00000000 bit 151413121110 9 8 accessrrrrrrrr reset00000000 bit 76543210 runstdby mode[2:0]=101 enable swrst access r/w r r r/w r/w r/w r/w r/w reset00000000
421 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 enabling this option is necessary for smbus compatibility, but can also be used in a non-smbus set-up. table 26-6. inactive timout calculated time-out periods are based on a 100khz baud rate. these bits are not synchronized. z bits 27:22 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 21:20 ? sdahold[1:0]: sda hold time these bits define the sda hold time with respect to the negative edge of scl. table 26-7. sda hold time these bits are not synchronized. z bits 19:17 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 16 ? pinout: pin usage this bit set the pin usage to either two- or four-wire operation: 0: 4-wire operation disabled. 1: 4-wire operation enabled. this bit is not synchronized. z bits 15:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 7 ? runstdby: run in standby this bit defines the functionality in standby sleep mode. 0: gclk_sercomx_core is disabled and the i 2 c master will not operate in standby sleep mode. 1: gclk_sercomx_core is enabled in all sleep modes al lowing the master to operate in standby sleep mode. this bit is not synchronized. value name description 0x0 dis disabled 0x1 55us 5-6 scl cycle time-out (50-60s) 0x2 105us 10-11 scl cycle time-out (100-110s) 0x3 205us 20-21 scl cycle time-out (200-210s) value name description 0x0 dis disabled 0x1 75ns 50-100ns hold time 0x2 450ns 300-600ns hold time 0x3 600ns 400-800ns hold time
422 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 6:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:2 ? mode[2:0]: operating mode these bits must be written to 0x5 to select the i 2 c master serial communication interface of the sercom. these bits are not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled. 1: the peripheral is enabled. due to synchronization, there is delay from writing ctrla.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. this bit is not enable-protected. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the serc om, except dbgctrl, to their initial state, and the ser- com will be disabled. writing a one to ctrla.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete. this bit is not enable-protected.
423 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.2 control b name: ctrlb offset: 0x04 reset: 0x00000000 property: write-protected, enable-protected, write-synchronized z bits 31:19 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 18 ? ackact: acknowledge action the acknowledge action (ackact) bit defines the i 2 c master's acknowledge behavior after a data byte is received from the i 2 c slave. the acknowledge action is executed when a command is written to ctrlb.cmd, or if smart mode is enabled (ctrlb.smen is wr itten to one), when data.data is read. 0: send ack. 1: send nack. this bit is not enable-protected. this bit is not write-synchronized. z bits 17:16 ? cmd[1:0]: command writing the command bits (cmd) triggers the master operation as defined in table 26-8 . the cmd bits are strobe bits, and always read as zero. the acknowledge action is only valid in master read mode. in master write mode, a command will only result in a repeated start or stop c ondition. the ctrlb.ackact bit and the cmd bits can be written at the same time, and then the acknowledge action will be updated before the command is triggered. bit3130292827262524 accessrrrrrrrr reset00000000 bit2322212019181716 ackact cmd[1:0] access r r r r r r/w r/w r/w reset00000000 bit151413121110 9 8 qcen smen accessrrrrrrrr/w reset00000000 bit76543210 accessrrrrrrrr reset00000000
424 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 commands can only be issued when the slave on bus interrupt flag (intflag.sb) or ma ster on bus interrupt flag (intflag.mb) is one. if cmd 0x1 is issued, a repeated start will be issued followed by the transmission of the current address in addr.addr. if another address is desired, addr.addr must be written instead of the cmd bits. this will trigger a repeated start followed by transmission of the new address. issuing a command will set status.syncbusy. table 26-8. command description these bits are not enable-protected. z bits 15:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 9 ? qcen: quick command enable setting the quick command enable bit (qcen) enables quick command. 0: quick command is disabled. 1: quick command is enabled. this bit is not write-synchronized. z bit 8 ? smen: smart mode enable this bit enables smart mode. when smart mode is enabl ed, acknowledge action is sent when data.data is read. 0: smart mode is disabled. 1: smart mode is enabled. this bit is not write-synchronized. z bits 7:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. cmd[1:0] dir action 0x0 x (no action) 0x1 x execute acknowledge action succeeded by repeated start 0x2 0 (write) no operation 1 (read) execute acknowledge action succeeded by a byte read operation 0x3 x execute acknowledge action succeed ed by issuing a stop condition
425 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.3 debug control name: dbgctrl offset: 0x08 reset: 0x00 property: write-protected z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? dbgstop: debug stop mode this bit controls functionality when the cpu is halted by an external debugger. 0: the baud-rate generator continues normal operati on when the cpu is halted by an external debugger. 1: the baud-rate generator is halted when the cpu is halted by an external debugger. bit76543210 dbgstop access r r r r r r r r/w reset00000000
426 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.4 baud rate name: baud offset: 0x0a reset: 0x0000 property: write-protected, enable-protected z bits 15:8 ? baudlow[7:0]: master baud rate low if the master baud rate low bit group (baudlow) has a non-zero value, the scl low time will be described by the value written. for more information on how to calculate the frequency, see ?sercom i2c ? sercom inter-integrated circuit? on page 387 . z bits 7:0 ? baud[7:0]: master baud rate the master baud rate bit group (baud) is used to deriv e the scl high time if baud.baudlow is non-zero. if baud.baudlow is zero, baud will be used to generate both high and low periods of the scl. for more information on how to calculate the frequency, see ?sercom i2c ? sercom inter-integrated circuit? on page 387 . bit151413121110 9 8 baudlow[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 baud[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
427 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.5 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x0c reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? sb: slave on bus interrupt enable 0: the slave on bus interrupt is disabled. 1: the slave on bus interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the slave on bus interrupt enable bit, which disables the slave on bus interrupt. z bit 0 ? mb: master on bus interrupt enable 0: the master on bus interrupt is disabled. 1: the master on bus interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the master on bus in terrupt enable bit, which disables the master on bus interrupt. bit76543210 sb mb accessrrrrrrr/wr/w reset00000000
428 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.6 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x0d reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? sb: slave on bus interrupt enable 0: the slave on bus interrupt is disabled. 1: the slave on bus interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the slave on bus interrupt enable bit, which enables the slave on bus interrupt. z bit 0 ? mb: master on bus interrupt enable 0: the master on bus interrupt is disabled. 1: the master on bus interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the master on bus interrupt enable bit, which enables the master on bus interrupt. bit76543210 sb mb accessrrrrrrr/wr/w reset00000000
429 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.7 interrupt flag status and clear name: intflag offset: 0x0e reset: 0x00 property: - z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? sb: slave on bus the slave on bus flag (sb) is set when a byte is successfully received in master read mode, i.e., no arbitration lost or bus error occurred during the operation. when this flag is set, the master forces the scl line low, stretching the i 2 c clock period. the scl line will be released and sb will be cleared on one of the following actions: z writing to addr.addr z writing to data.data z reading data.data when smart mode is enabled (ctrlb.smen) z writing a valid command to ctrlb.cmd writing a one to this bit location will clear the sb flag. the transaction will not continue or be terminated until one of the above actions is performed. writing a zero to this bit has no effect. z bit 0 ? mb: master on bus the master on bus flag (mb) is set when a byte is transmitt ed in master write mode. the flag is set regardless of the occurrence of a bus error or an arbitration lost conditi on. mb is also set when arbitration is lost during sending of nack in master read mode, and when issuing a start cond ition if the bus state is unknown. when this flag is set and arbitration is not lost, the master forces the scl line low, stretching the i 2 c clock period. the scl line will be released and mb will be cleared on one of the following actions: z writing to addr.addr z writing to data.data z reading data.data when smart mode is enabled (ctrlb.smen) z writing a valid command to ctrlb.cmd if arbitration is lost, writing a one to this bit location will clear the mb flag. if arbitration is not lost, writing a one to this bit location will clear the mb flag. the transaction will not continue or be terminated until one of the above actions is performed. writing a zero to this bit has no effect. bit76543210 sb mb accessrrrrrrr/wr/w reset00000000
430 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.8 status name: status offset: 0x10 reset: 0x0000 property: write-synchronized z bit 15 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 14:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 7 ? clkhold: clock hold the master clock hold flag (status.clkhold) is set when the master is holding the scl line low, stretching the i 2 c clock. software should consider this bit a read-only status flag that is set when intflag.sb or int- flag.mb is set. when the corresponding interrupt flag is cleared and the next operation is given, this bit is automatically cleared. writing a zero to this bit has no effect. writing a one to this bit has no effect. this bit is not write-synchronized. z bit 6 ? lowtout: scl low time-out this bit is set if an scl low time-out occurs. writing a one to this bit location will clear status.lowtout. normal use of the i 2 c interface does not require the lowtout flag to be cleared by this method. this fl ag is automatically cleared when writing to the addr register. writing a zero to this bit has no effect. this bit is not write-synchronized. z bits 5:4 ? busstate[1:0]: bus state these bits indicate the current i 2 c bus state as defined in table 26-9 . after enabling the sercom as an i 2 c mas- ter, the bus state will be unknown. bit151413121110 9 8 syncbusy accessrrrrrrrr reset00000000 bit76543210 clkhold lowtout busstate[1:0] rxnack arblost buserr access r r/w r r/w r r r/w r/w reset00000000
431 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 26-9. bus state when the master is disabled, the bus-state is unknown. when in the unknown state, writing 0x1 to busstate forces the bus state into the idle state. the bus state cannot be forced into any other state. writing status.busstate to id le will set status.syncbusy. z bit 3 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 2 ? rxnack: received not acknowledge this bit indicates whether the last address or data packet sent was acknowledged or not. 0: slave responded with ack. 1: slave responded with nack. writing a zero to this bit has no effect. writing a one to this bit has no effect. this bit is not write-synchronized. z bit 1 ? arblost: arbitration lost the arbitration lost flag (status.arblost) is set if ar bitration is lost while transmitting a high data bit or a nack bit, or while issuing a start or repeated start condi tion on the bus. the master on bus interrupt flag (int- flag.mb) will be set when status.arblost is set. writing the addr.addr register will automatically clear status.arblost. writing a zero to this bit has no effect. writing a one to this bit will clear it. this bit is not write-synchronized. z bit 0 ? buserr: bus error the bus error bit (status.buserr) indicates that an illegal bus condition has occurred on the bus, regardless of bus ownership. an illegal bus condition is detected if a protocol violating start, repeated start or stop is detected on the i 2 c bus lines. a start condition directly followed by a st op condition is one example of a protocol violation. if a time-out occurs during a frame, this is also considered a protocol violation, and will set buserr. if the i 2 c master is the bus owner at the time a bus erro r occurs, status.arblost and intflag.mb will be set in addition to buserr. writing the addr.addr register will automatically clear the buserr flag. writing a zero to this bit has no effect. writing a one to this bit will clear it. this bit is not write-synchronized. value name description 0x0 unknown the bus state is unknown to the i 2 c master and will wait for a stop condition to be detected or wait to be forced into an idle state by software 0x1 idle the bus state is waiting for a transaction to be initialized 0x2 owner the i 2 c master is the current owner of the bus 0x3 busy some other i 2 c master owns the bus
432 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.9 address name: addr offset: 0x14 reset: 0x0000 property: write-synchronized z bits 15:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? addr[7:0]: address when addr is written, the consecutive operation will depend on the bus state: unknown: intflag.mb and status.buser r are set, and the operation is terminated. busy: the i 2 c master will await further operation until the bus becomes idle. idle: the i 2 c master will issue a start condition followed by the address written in addr. if the address is acknowl- edged, scl is forced and held low, and stat us.clkhold and intflag.mb are set. owner: a repeated start sequence will be performed. if the previous transaction was a read, the acknowledge action is sent before the repeated start bus condition is issued on the bus. writing addr to issue a repeated start is performed while intflag.mb or intflag.sb is set. regardless of winning or losing arbitration, the entire address will be sent. if arbitration is lost, only ones are trans- mitted from the point of losing arbitration and the rest of the address length. status.buserr, stat us.arblost, intflag.mb and intflag.sb will be cleared when addr is written. the addr register can be read at any time without interfering with ongoing bus activity, as a read access does not trigger the master logic to perform any bus protocol related operations. the i 2 c master control logic uses bit 0 of addr as the bus protocol?s read/write flag (r/w); 0 for write and 1 for read. bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 addr[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
433 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 26.8.2.10 data name: data offset: 0x18 reset: 0x0000 property: write-synchronized, read-synchronized z bits 15:8 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 7:0 ? data[7:0]: data the master data register i/o location (data) provides access to the master transmit and receive data buffers. reading valid data or writing data to be transmitted can be successfully done only when scl is held low by the master (status.clkhold is set). an exception occurs when reading the last data byte after the stop condition has been sent. accessing data.data auto-triggers i 2 c bus operations. the operation performed depends on the state of ctrlb.ackact, ctrlb.smen and the type of access (read/write). writing or reading data.data when not in smart mode does not require synchronization. bit151413121110 9 8 accessrrrrrrrr reset00000000 bit76543210 data[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
434 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27. tc ? timer/counter 27.1 overview the tc consists of a counter, a prescaler, compare/capture channels and control logic. the counter can be set to count events, or it can be configured to count clock pulses. t he counter, together with the compare/capture channels, can be configured to timestamp input events, allowing capture of frequency and pulse width. it can also perform waveform generation, such as frequency generation and pulse-width modulation (pwm) . 27.2 features z selectable configuration z 8-, 16- or 32-bit tc, wit h compare/capture channels z waveform generation z frequency generation z single-slope pulse-width modulation z input capture z event capture z frequency capture z pulse-width capture z one input event z interrupts/output events on: z counter overflow/underflow z compare match or capture z internal prescaler
435 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.3 block diagram figure 27-1. timer/counter block diagram per p e r prescaler p r e s c a l e r control c o n t r o l logic l o g i c waveform w a v e f o r m generation g e n e r a t i o n count c o u n t cc0 c c 0 base counter b a s e c o u n t e r counter c o u n t e r compare / capture c o m p a r e / c a p t u r e top t o p zero z e r o = 0 = 0 = match m a t c h update u p d a t e event e v e n t = ovf/unf o v f / u n f (int req.) ( i n t r e q . ) err e r r (int req.) ( i n t r e q . ) wox out w o x o u t mcx m c x (int req.) ( i n t r e q . ) count c o u n t clear c l e a r load l o a d direction d i r e c t i o n control c o n t r o l logic l o g i c
436 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 27.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 27.5.1 i/o lines using the tc?s i/o lines requires the i/o pins to be configured. refer to ?port? on page 280 for details. 27.5.2 power management the tc can continue to operate in any sleep mode where the selected source clock is running. the tc interrupts can be used to wake up the device from sleep modes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 27.5.3 clocks the tc bus clock (clk_tcx_apb, where x represents the specific tc instance number) can be enabled and disabled in the power manager, and the default state of clk_tcx_apb can be found in the peripheral clock masking section in ?pm ? power manager? on page 101 . the different tc instances are paired, even and odd, starti ng from tc0, and use the same generic clock, gclk_tcx. this means that the tc instances in a tc pair cannot be set up to use different gclk_tcx clocks. this generic clock is asynchronous to the user interface cl ock (clk_tcx_apb). due to th is asynchronicity, accessing certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 445 for further details. 27.5.4 interrupts the interrupt request line is connected to the interrupt controll er. using the tc interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 27.5.5 events to use the tc event functionality, the corresponding events need to be configured in the event system. refer to ?evsys ? event system? on page 306 for details. 27.5.6 debug operation when the cpu is halted in debug mode the tc will halt normal operation. the tc can be forced to continue operation during debugging. refer to the dbgctrl register for details. 27.5.7 register access protection all registers with write-access are optionally write-protect ed by the peripheral access controller (pac), except the following registers: z interrupt flag register ( intflag ) z status register ( status ) signal name type description wo[1:0] digital output waveform output
437 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z read request register ( readreq ) z count register (count), ?counter value? on page 467 z period register (per), ? period value? on page 470 z compare/capture value registers (ccx), ? compare/capture? on page 471 write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all wr ite-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 27.5.8 analog connections not applicable. 27.6 functional description 27.6.1 principle of operation the counter in the tc can be set to count on events from the event system, or on the gclk_tcx frequency. the pulses from gclk_tcx will go through the prescaler, w here it is possible to divide the frequency down. the value in the counter is passed to the compare/capture channels, where it can either be compared with user defined values or captured on a predefined event. the tc can be configured as an 8-, 16- or 32-bit counter . which mode is chosen will determine the maximum range of the counter. the counter range combined with the operat ing frequency will determine the maximum time resolution achievable with the tc peripheral. the tc can be count up or down. by default, the counter will operate in a continuous mode and count up, where the counter will wrap to the zero when reaching the top value when one of the compare/capture channels is used in compare mode, the tc can be used for waveform generation. upon a match between the counter and the value in one or more of the compare/capture value registers (ccx), one or more output pins on the device can be set to toggle. the ccx registers and the counter can thereby be used in frequency generation and pwm generation. capture mode can be used to automatically capture the period and pulse width of signals. 27.6.2 basic operation 27.6.2.1 initialization the following register is enable-protected, meaning that it can only be written when the tc is disabled (ctrla.enable is zero): z control a register ( ctrla ), except the run standby (runstdby), enable (enable) and software reset (swrst) bits the following bits are enable-protected: z event action bits in the event control register (evctrl.evact) enable-protected bits in the ctrla register can be written at the same time as ctrla.enable is written to one, but not at the same time as ctrla.enable is written to zero. before the tc is enabled, it must be configured, as outlined by the following steps: z the tc bus clock (clk_tcx_apb) must be enabled z the mode (8, 16 or 32 bits) of the tc must be selected in the tc mode bit group in the control a register (ctrla.mode). the default mode is 16 bits z one of the wavegen modes must be selected in the waveform generation operation bit group in the control a register (ctrla.wavegen)
438 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z if the gclk_tcx frequency used should be prescaled, this can be selected in the prescaler bit group in the control a register (ctrla.prescaler) z if the prescaler is used, one of the presync modes mu st be chosen in the prescaler and counter synchronization bit group in the control a register (ctrla.presync) z one-shot mode can be selected by writing a one to the one-shot bit in the control b set register (ctrlbset.oneshot) z if the counter should count down from the top value, writ e a one to the counter direction bit in the control b set register (ctrlbset.dir) z if capture operations are to be used, the individual channels must be enabled for capture in the capture channel x enable bit group in the contro l c register (ctrlc.cpten) z the waveform output for individual channels can be inverted using the waveform output invert enable bit group in the control c register (ctrlc.inven) 27.6.2.2 enabling, disabling and resetting the tc is enabled by writing a one to the enable bit in the c ontrol a register (ctrla.enable). the tc is disabled by writing a zero to ctrla.enable. the tc is reset by writing a one to the software reset bit in the control a register (ctrla .swrst). all registers in the tc, except dbgctrl, will be reset to their initial state, and the tc will be disabled. refer to the ctrla register for details. the tc should be disabled before the tc is reset to avoid undefined behavior. 27.6.2.3 prescaler selection as seen in figure 27-2 , the gclk_tc clock is fed into the internal prescaler. prescaler output intervals from 1 to 1/1024 are available. for a complete list of available prescaler outputs, see the register description for the prescaler bit group in the control a register (ctrla.prescaler). the prescaler consists of a counter that counts to the selected prescaler value, whereupon the output of the prescaler toggles. when the prescaler is set to a value greater than one, it is necessary to choose whether the prescaler should reset its value to zero or continue counting from its current value on the occurrence of an overflow or underflow. it is also necessary to choose whether the tc counter should wrap around on the next gclk_tc clock pulse or the next prescaled clock pulse (clk_tc_cnt of figure 27-2 ). to do this, use the prescaler and counter synchronization bit group in the control a r egister (ctrla.presync). if the counter is set to count events from the event system, these will not pass through the prescaler, as seen in figure 27-2 . figure 27-2. prescaler 27.6.2.4 tc mode the counter mode is selected with the tc mode bit group in the control a register (ctrla.mode). by default, the counter is enabled in the 16-bit counter mode. three counter modes are available: event cnt prescaler prescaler evact gclk_tc gclk_tc / {1,2,4,8,64,256,1024 } clk_tc_cnt
439 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z count8: the 8-bit tc has its own period register (per). this register is used to store the period value that can be used as the top value for waveform generation. z count16: this is the default counter mode. ther e is no dedicated period register in this mode. z count32: this mode is achieved by pairing two 16- bit tc peripherals. this pairing is explained in ?clocks? on page 436 . the even-numbered tc instance will act as master to the odd-numbered tc peripheral, which will act as a slave. the slave status of the slave is indicated by reading the slave bit in the status register (status.slave). the registers of the slave will not reflect t he registers of the 32-bit counter. writing to any of the slave registers will not affect the 32-bit counter. normal access to the slave count and ccx registers is not allowed. 27.6.2.5 counter operations the counter can be set to count up or down. when the counter is counting up and the top value is reached, the counter will wrap around to zero on the next clock cycle. when counting down, the counter will wrap around to the top value when zero is reached. in one-shot mode, the counter will stop counting after a wraparound occurs. to set the counter to count down, write a one to the direction bit in the control b set regist er (ctrlbset.dir). to count up, write a one to the direction bit in t he control b clear register (ctrlbclr.dir). each time the counter reaches the top value or zero, it will set the overflow interrupt flag in the interrupt flag status and clear register (intflag.ovf). it is also possible to generate an event on overflow or underflow when the overflow/underflow event output enable bit in t he event control register (evctrl.ovfeo) is one. the counter value can be read from the counter value regi ster (count) or a new value can be written to the count register. figure 27-3 gives an example of writing a new counter value. the count value will always be zero when starting the tc, unless some other value has been written to it or if the tc has been previously reloaded at top value, because stopped while tc was counting down. figure 27-3. counter operation stop command on the stop command, which can be evoked in the command bi t group in the control b set register (ctrlbset.cmd), the counter will retain its current value. all waveforms ar e cleared. the counter stops counting, and the stop bit in the status register is set (status.stop). retrigger command and event action retriggering can be evoked either as a software command, us ing the retrigger command in the control b set register (ctrlbset.cmd), or as a retrigger ev ent action, using the event action bit group in the event control register (evctrl.evact). when a retrigger is evoked while the counter is running, t he counter will wrap to the top value or zero, depending on the counter direction.. dir count top count written direction change period (t) bot "update "
440 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 when a retrigger is evoked with the counter stopped, the counter will continue counting from the value in the count register. note: when retrigger event action is configured and enabled as an event action, enabling the counter will not start the counter. the counter will start at the next incoming event and restart on any following event. count event action when the count event action is configured, every new inco ming event will make the counter increment or decrement, depending on the state of the direction bit (ctrlbset.dir). start event action when the tc is configured with a start event action in the evctrl.evact bit group, enabling the tc does not make the counter start; the start is postponed until the next input event or software retrigger action. when the counter is running, an input event has not effect on the counter. 27.6.2.6 compare operations when using the tc with the compare/capture value regist ers (ccx) configured for compare operation, the counter value is continuously compared to the values in the ccx registers. this can be used for timer or waveform operation. waveform output operations the compare channels can be used for waveform generation on the corresponding i/o pins. to make the waveform visible on the connected pin, the following requirements must be fulfilled: z choose a waveform generation operation z optionally, invert the waveform output by writing the corresponding waveform output invert enable bit in the control c register (ctrlc.invx) z enable the corresponding multiplexor in the port the counter value is continuously compared with each ccx available. when a compare match occurs, the match or capture channel x interrupt flag in the interrupt flag status and clear register (intflag.mcx) is set on the next zero-to- one transition of clk_tc_cnt (see figure 27-4 ). an interrupt and/or event can be generated on such a condition when intenset.mcx and/or evctrl.mceox is one. one of four configurations in the waveform generation oper ation bit group in the control a register (ctrla.wavegen) must be chosen to perform waveform generation. this will influence how the waveform is generated and impose restrictions on the top value. the four configurations are: z normal frequency (nfrq) z match frequency (mfrq) z normal pwm (npwm) z match pwm (mpwm) when using npwm or nfrq, the top value is determined by t he counter mode. in 8-bit mode, the period register (per) is used as the top value and the top value can be changed by writing to the per register. in 16- and 32-bit mode, the top value is fixed to the maximum value of the counter. frequency operation when nfrq is used, the waveform output (wo[x]) toggles every time ccx and the counter are equal, and the interrupt flag corresponding to that channel will be set.
441 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 27-4. normal frequency operation when mfrq is used, the value in cc0 will be used as th e top value and wo[0] will toggle on every overflow/underflow. figure 27-5. match frequency operation pwm operation in pwm operation, the ccx registers control the duty cycle of the waveform generator output. figure 27-6 shows how in count-up the wo[x] output is set at a start or compare match between the count value and the top value and cleared on the compare match between the count value and ccx register value. in count-down the wo[x] output is cleared at start or compare match between the count value and the top value and set on the compare match between the count value and ccx register value. count zero "wraparound " top cnt written ccx wo[x] count " wraparound " top count written direction change period (t) zero wo[0]
442 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 27-6. normal pwm operation in match operation, compare/capture register cc0 is used as the top value, in this case a negative pulse will appear on wo[0] on every overflow/underflow. the following equation is used to calculate the exact period for a single-slope pwm (r pwm_ss ) waveform: where n represent the prescaler divider used (1, 2, 4, 8, 16, 64, 256, 1024). changing the top value changing the top value while the counter is running is possible. if a new top value is written when the counter value is close to zero and counting down, the counter can be reloaded with the previous top value, due to synchronization delays. if this happens, the counter will count one extra cycle before the new top value is used. figure 27-7. changing the top value when counting down count top period (t) "match " zero wo[x] ccn= bot cc n ccn= top "wraparound " r pwm_ss top 1 + () log 2 () log ------------------ ---------------- - = f pwm_ss f clk_tc ntop 1 + () ---------------- -------------- = count max "reload" "write" zero new top value that is higher than current count new top value that is lower than current count
443 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 when counting up a change from a top value that is lower relati ve to the old top value can make the counter miss this change if the counter value is larger than the new top value when the change occurred. this will make the counter count to the max value. an example of this can be seen in figure 27-8 . figure 27-8. changing the top value when counting up 27.6.2.7 capture operations to enable and use capture operations, the event line into the tc must be enabled using the tc event input bit in the event control register (evctrl.tcei). the capture channel s to be used must also be enabled in the capture channel x enable bit group in the control c register (c trlc.cptenx) before capture can be performed. event capture action the compare/capture channels can be used as input capture channels to capture any event from the event system and give them a timestamp. because all capture channels us e the same event line, only one capture channel should be enabled at a time when performing event capture. figure 27-9 shows four capture events for one capture channel. figure 27-9. input capture timing when the capture interrupt flag is set and a new capture event is detected, there is nowhere to store the new timestamp. as a result, the error interrupt flag in the interrupt flag status and clear register (intflag.err) is set. count max counter wraparound " wraparound " "write" zero new top value that is lower than current count new top value that is higher than current count events count top zero capture 0 capture 1 capture 2 capture 3
444 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 period and pulse-width capture action the tc can perform two input captures and restart the count er on one of the edges. this enables the tc to measure the pulse width and period. this can be used to characterize the frequency and duty cycle of an input signal: when using ppw event action, the period (t) will be captured into cc0 and the pulse width (tp) in cc1. in pwp event action, the pulse width (tp) will be capt ured in cc0 and the period (t) in cc1. selecting pwp (pulse-width, period) or ppw (period, pulse-width) in the event action bit group in the event control register (evctrl.evact) enables the tc to performs two capture actions, one on the rising edge and one on the falling edge. the tc inverted event input in the event control register (evctrl.tcinv) is used to select whether the wraparound should occur on the rising edge or the falling edge. if evct rl.tcinv is written to one, the wraparound will happen on the falling edge. the event source to be captured must be an asynchronous event. to fully characterize the frequency and duty cycle of the input signal, activate capture on cc0 and cc1 by writing 0x3 to the capture channel x enable bit group in the contro l c register (ctrlc.cpten ). when only one of these measurements is required, the second channel can be used for other purposes. the tc can detect capture overflow of the input captur e channels. when the capture interrupt flag is set and a new capture event is detected, there is nowhere to store the new timestamp. asa result, intflag.err is set. 27.6.3 additional features 27.6.3.1 one-shot operation when one-shot operation is enabled, the counter automatic ally stops on the next counter overflow or underflow condition. when the counter is stopped, status.stop is aut omatically set by hardware and the waveform outputs are set to zero. one-shot operation can be enabled by writing a one into the one-shot bit in the control b set register (ctrlbset.oneshot) and disabled by writing a one to the one-shot bit in the control b clear register (ctrlbclr.oneshot). when enabled, it will count until an overflow or underflow occurs. the one-shot operation can be restarted with a retrigger command, a retrigger event or a start event. when the counter restarts its operation, the stop bit in the st atus register (status.stop) is automatically cleared by hardware. 27.6.4 interrupts the tc has the following interrupt sources: z overflow/underflow: ovf z compare or capture channels z capture overflow error: err z synchronization ready: syncrdy each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one f 1 t -- - = dutycycle t p t --- - =
445 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the tc is reset. see the intflag register for details on how to clear interrupt flags. the tc has one common interrupt request line for all the interr upt sources. the user must read the intflag register to determine which interrupt condition is present. note that inte rrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 27.6.5 events the tc can generate the following output events: z overflow/underflow (ovf) z match or capture (mc) writing a one to an event output bit in the event control register (evctrl . mceo) enables the corresponding output event. writing a zero to this bit disables the corresponding output event. to enable one of the following event actions, writ e to the event action bit group (evctrl.evact). z start the counter z retrigger counter z increment or decrement counter (depends on counter direction) z capture event z capture period z capture pulse width writing a one to the tc event input bit in the event cont rol register (evctrl.tcei) enables input events to the tc. writing a zero to this bit disables input events to the tc. refer to ?evsys ? event system? on page 306 for details on configuring the event system. 27.6.6 sleep mode operation the tc can be configured to operate in any sleep mode. to be able to run in standby, the runstdby bit in the control a register (ctrla.runstdby) must be wr itten to one. the tc can wake up the device using interrupts from any sleep mode or perform actions through the event system. 27.6.7 synchronization due to the asynchronicity between clk_tcx_apb and gc lk_tcx some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register(status.syncbusy) will be set immediately, and cleared when synchronization is complete. the synchronization ready interrupt can be used to signal when sync is complete. this can be accessed via the synchronization ready interrupt flag in the interrupt flag status and clear register (intflag.syncrdy). if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in the control a register (ctrla.swrst) z enable bit in the control a register (ctrla.enable)
446 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 write-synchronization is denoted by the write-synchronized property in the register description. the following registers need synchronization when written: z control b clear register (ctrlbclr) z control b set register (ctrlbset) z control c register (ctrlc) z count value register (count) z period value register (period) z compare/capture value registers (ccx) write-synchronization is denoted by the write-synchronized property in the register description. the following registers need synchronization when read: z control b clear register (ctrlbclr) z control b set register (ctrlbset) z control c register (ctrlc) z count value register (count) z period value register (period) z compare/capture value registers (ccx) read-synchronization is denoted by the read-synchronized property in the register description.
447 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.7 register summary table 27-1. register summar y ? 8-bit mode registers offset name bit pos. 0x00 ctrla 7:0 wavegen[1:0] mode[1:0] enable swrst 0x01 15:8 prescsync[1:0] runstdby prescaler[2:0] 0x02 readreq 7:0 addr[4:0] 0x03 15:8 rreq rcont 0x04 ctrlbclr 7:0 cmd[1:0] oneshot dir 0x05 ctrlbset 7:0 cmd[1:0] oneshot dir 0x06 ctrlc 7:0 cpten1 cpten0 inven1 inven0 0x07 reserved 0x08 dbgctrl 7:0 dbgrun 0x09 reserved 0x0a evctrl 7:0 tcei tcinv evact[2:0] 0x0b 15:8 mceo1 mceo0 ovfeo 0x0c intenclr 7:0 mc1 mc0 syncrdy err ovf 0x0d intenset 7:0 mc1 mc0 syncrdy err ovf 0x0e intflag 7:0 mc1 mc0 syncrdy err ovf 0x0f status 7:0 syncbusy slave stop 0x10 count 7:0 count[7:0] 0x11 reserved 0x12 reserved 0x13 reserved 0x14 per 7:0 per[7:0] 0x15 reserved 0x16 reserved 0x17 reserved 0x18 cc0 7:0 cc[7:0] 0x19 cc1 7:0 cc[7:0] 0x1a reserved 0x1b reserved 0x1c reserved 0x1d reserved 0x1e reserved 0x1f reserved
448 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 27-2. register summary ? 16-bit mode registers offset name bit pos. 0x00 ctrla 7:0 wavegen[1:0] mode[1:0] enable swrst 0x01 15:8 prescsync[1:0] runstdby prescaler[2:0] 0x02 readreq 7:0 addr[4:0] 0x03 15:8 rreq rcont 0x04 ctrlbclr 7:0 cmd[1:0] oneshot dir 0x05 ctrlbset 7:0 cmd[1:0] oneshot dir 0x06 ctrlc 7:0 cpten1 cpten0 inven1 inven0 0x07 reserved 0x08 dbgctrl 7:0 dbgrun 0x09 reserved 0x0a evctrl 7:0 tcei tcinv evact[2:0] 0x0b 15:8 mceo1 mceo0 ovfeo 0x0c intenclr 7:0 mc1 mc0 syncrdy err ovf 0x0d intenset 7:0 mc1 mc0 syncrdy err ovf 0x0e intflag 7:0 mc1 mc0 syncrdy err ovf 0x0f status 7:0 syncbusy slave stop 0x10 count 7:0 count[7:0] 0x11 15:8 count[15:8] 0x12 reserved 0x13 reserved 0x14 reserved 0x15 reserved 0x16 reserved 0x17 reserved 0x18 cc0 7:0 cc[7:0] 0x19 15:8 cc[15:8] 0x1a cc1 7:0 cc[7:0] 0x1b 15:8 cc[15:8] 0x1c reserved 0x1d reserved 0x1e reserved 0x1f reserved
449 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 27-3. register summary ? 32-bit mode registers offset name bit pos. 0x00 ctrla 7:0 wavegen[1:0] mode[1:0] enable swrst 0x01 15:8 prescsync[1:0] runstdby prescaler[2:0] 0x02 readreq 7:0 addr[4:0] 0x03 15:8 rreq rcont 0x04 ctrlbclr 7:0 cmd[1:0] oneshot dir 0x05 ctrlbset 7:0 cmd[1:0] oneshot dir 0x06 ctrlc 7:0 cpten1 cpten0 inven1 inven0 0x07 reserved 0x08 dbgctrl 7:0 dbgrun 0x09 reserved 0x0a evctrl 7:0 tcei tcinv evact[2:0] 0x0b 15:8 mceo1 mceo0 ovfeo 0x0c intenclr 7:0 mc1 mc0 syncrdy err ovf 0x0d intenset 7:0 mc1 mc0 syncrdy err ovf 0x0e intflag 7:0 mc1 mc0 syncrdy err ovf 0x0f status 7:0 syncbusy slave stop 0x10 count 7:0 count[7:0] 0x11 15:8 count[15:8] 0x12 23:16 count[23:16] 0x13 31:24 count[31:24] 0x14 reserved 0x15 reserved 0x16 reserved 0x17 reserved 0x18 cc0 7:0 cc[7:0] 0x19 15:8 cc[15:8] 0x1a 23:16 cc[23:16] 0x1b 31:24 cc[31:24] 0x1c cc1 7:0 cc[7:0] 0x1d 15:8 cc[15:8] 0x1e 23:16 cc[23:16] 0x1f 31:24 cc[31:24]
450 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to the ?register access protection? on page 436 and the ?pac ? peripheral access controller? on page 28 for details. some registers require synchronization when read and/or wr itten. synchronization is denoted by the write-synchronized or read-synchronized property in each individual register description. refer to ?synchronization? on page 445 for details. some registers are enable-protected, meaning they can only be written when the tc is disabled. enable-protection is denoted by the enable-protected property in each individual register description.
451 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.1 control a name: ctrla offset: 0x00 reset: 0x0000 property: write-protected, enable-protected, write-synchronized z bits 15:14 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 13:12 ? prescsync[1:0]: prescal er and counter synchronization these bits select whether on start or retrigger event the counter should wrap around on the next gclk_tcx clock or the next prescaled gclk_tcx clock. it?s also possible to reset the prescaler. the options are as shown in table 27-4 . these bits are not synchronized. table 27-4. prescaler and counter synchronization z bit 11 ? runstdby: run in standby this bit is used to keep the tc running in standby mode: 0: the tc is halted in standby. 1: the tc continues to run in standby. this bit is not synchronized. z bits 10:8 ? prescaler[2:0]: prescaler these bits select the counter prescaler factor, as shown in table 27-5 . these bits are not synchronized. bit151413121110 9 8 prescsync[1:0] runstd by prescaler[2:0] access r r r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 wavegen[1:0] mode[1:0] enable swrst access r r/w r/w r r/w r/w r/w r/w reset00000000 value name description 0x0 gclk reload or reset the counter on next generic clock 0x1 presc reload or reset the counter on next prescaler clock 0x2 resync reload or reset the counter on next gen eric clock. reset the prescaler counter 0x3 - reserved
452 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 27-5. prescaler z bit 7 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 6:5 ? wavegen[1:0]: w aveform generation operation these bits select the waveform generation operation. they affect the top value, as shown in ?waveform output operations? on page 440 . it also controls whether frequency or pwm waveform generation should be used. how these modes differ can also be seen from ?waveform output operations? on page 440 . these bits are not synchronized. table 27-6. waveform generation operation note: 1. this depends on the tc mode. in 8-bit mode, the t op value is the period value register (per). in 16- and 32-bit mode it is the maximum value. z bit 4 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 3:2 ? mode[1:0]: tc mode these bits select the tc mode, as shown in table 27-7 . these bits are not synchronized. value name description 0x0 div1 prescaler: gclk_tc 0x1 div2 prescaler: gclk_tc/2 0x2 div4 prescaler: gclk_tc/4 0x3 div8 prescaler: gclk_tc/8 0x4 div16 prescaler: gclk_tc/16 0x5 div64 prescaler: gclk_tc/64 0x6 div256 prescaler: gclk_tc/256 0x7 div1024 prescaler: gclk_tc/1024 value name operation top value waveform output on match waveform output on wraparound 0x0 nfrq normal frequency per (1) /max toggle no action 0x1 mfrq match frequency cc0 toggle no action 0x2 npwm normal pwm per (1) /max clear when counting up set when counting down set when counting up clear when counting down 0x3 mpwm match pwm cc0 clear when counting up set when counting down set when counting up clear when counting down
453 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 27-7. tc mode z bit 1 ? enable: enable 0: the peripheral is disabled. 1: the peripheral is enabled. due to synchronization, there is delay from writing ctrla.enable until the peripheral is enabled/disabled. the value written to ctrla.enable will read back immediat ely, and the synchronization busy bit in the status regis- ter (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the tc, except dbgctrl, to their initial state, and the tc will be disabled. writing a one to ctrla.swrst will always take precedence; all other writes in the same write-operation will be discarded. due to synchronization there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete. value name description 0x0 count16 counter in 16-bit mode 0x1 count8 counter in 8-bit mode 0x2 count32 counter in 32-bit mode 0x3 - reserved
454 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.2 read request for a detailed description of this register and its use, refer to the ?synchronization? on page 445 . name: readreq offset: 0x02 reset: 0x0000 property: - z bit 15 ? rreq: read request writing a zero to this bit has no effect. this bit will always read as zero. writing a one to this bit requests synchronization of the register pointed to by the address bit group (read- req.addr) and sets the synchronization busy bit in the status register (status.syncbusy). z bit 14 ? rcont: read continuously 0: continuous synchronization is disabled. 1: continuous synchronization is enabled. when continuous synchronization is enabled, the register pointed to by the address bit group (readreq.addr) will be synchronized automatically every time the register is updated. z bits 13:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:0 ? addr[4:0]: address these bits select the offset of the register that needs read synchronization. in the tc, only count and ccx are available for read synchronization. bit151413121110 9 8 rreq rcont accesswr/wrrrrrr reset00000000 bit76543210 addr[4:0] access r r r r/w r/w r/w r/w r/w reset00000000
455 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.3 control b clear this register allows the user to change this register without doing a read-modify-write operation. changes in this register will also be reflected in the control b set (ctrlbset) register. name: ctrlbclr offset: 0x04 reset: 0x00 property: write-protected, write-synchronized, read-synchronized z bits 7:6 ? cmd[1:0]: command these bits are used for software control of retriggering and stopping the tc. when a command has been exe- cuted, the cmd bit group will read back as zero. the commands are executed on the next prescaled gclk_tc clock cycle. writing a zero to one of these bits has no effect. writing a one to one of these bits will clear the pending command. table 27-8. command z bits 5:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? oneshot: one-shot this bit controls one-shot operation of the tc. when in one-shot mode, the tc will stop counting on the next over- flow/underflow condition or a stop command. 0: the tc will wrap around and continue c ounting on an overflow/underflow condition. 1: the tc will wrap around and stop on the next underflow/overflow condition. writing a zero to this bit has no effect. writing a one to this bit will disable one-shot operation. z bit 1 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 0 ? dir: counter direction this bit is used to change the direction of the counter. 0: the timer/counter is counting up (incrementing). bit76543210 cmd[1:0] oneshot dir access r/w r/w r r r r/w r r/w reset00000000 value name description 0x0 none no action 0x1 retrigger force a start, restart or retrigger 0x2 stop force a stop 0x3 - reserved
456 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1: the timer/counter is c ounting down (decrementing). writing a zero to this bit has no effect. writing a one to this bit will make the counter count up.
457 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.4 control b set this register allows the user to change this register without doing a read-modify-write operation. changes in this register will also be reflected in the control b set (ctrlbclr) register. name: ctrlbset offset: 0x05 reset: 0x00 property: write-protected, write-synchronized, read-synchronized z bits 7:6 ? cmd[1:0]: command these bits is used for software control of retri ggering and stopping the tc. when a command has been executed, the cmd bit group will be read back as zero. the commands are executed on the next prescaled gclk_tc clock cycle. writing a zero to one of these bits has no effect. writing a one to one of these bits will set a command. table 27-9. command z bits 5:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? oneshot: one-shot this bit controls one-shot operation of the tc. when active, the tc will stop counting on the next overflow/under- flow condition or a stop command. 0: the tc will wrap around and continue c ounting on an overflow/underflow condition. 1: the timer/counter will wrap around and stop on the next underflow/overflow condition. writing a zero to this bit has no effect. writing a one to this bit will enable one-shot operation. z bit 1 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 0 ? dir: counter direction this bit is used to change the direction of the counter. 0: the timer/counter is counting up (incrementing). bit76543210 cmd[1:0] oneshot dir access r/w r/w r r r r/w r r/w reset00000000 value name description 0x0 none no action 0x1 retrigger force a start, restart or retrigger 0x2 stop force a stop 0x3 - reserved
458 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 1: the timer/counter is c ounting down (decrementing). writing a zero to this bit has no effect writing a one to this bit will make the counter count down.
459 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.5 control c name: ctrlc offset: 0x06 reset: 0x00 property: write-protected, write-synchronized, read-synchronized z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:4 ? cptenx: capture channel x enable these bits are used to select whether channel x is a capture or a compare channel. writing a one to cptenx enables capture on channel x. writing a zero to cptenx disables capture on channel x. z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? invenx: waveform output x invert enable these bits are used to select inversion on the output of channel x. writing a one to invenx inverts the output from wo[x]. writing a zero to invenx disables inversion of the output from wo[x]. bit76543210 cpten1 cpten0 inven1 inven0 access r r r/w r/w r r r/w r/w reset00000000
460 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.6 debug control name: dbgctrl offset: 0x08 reset: 0x00 property: write-protected z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? dbgrun: debug run mode this bit is not affected by a software reset, and should not be changed by software while the tc is enabled. 0: the tc is halted when the device is halted in debug mode. 1: the tc continues normal operation when the device is halted in debug mode. bit76543210 dbgrun access r r r r r r r r/w reset00000000
461 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.7 event control name: evctrl offset: 0x0a reset: 0x0000 property: write-protected, enable-protected z bits 15:14 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 13:12 ? mceox: match or capt ure channel x event output enable these bits control whether event match or capture on channel x is enabled or not and generated for every match or capture. 0: match/capture event on channel x is disabled and will not be generated. 1: match/capture event on channel x is enabled and will be generated for every compare/capture. these bits are not enable-protected. z bits 11:9 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 8 ? ovfeo: overflow/unde rflow event ou tput enable this bit is used to enable the overflow/underflow event. when enabled an event will be generated when the coun- ter overflows/underflows. 0: overflow/underflow event is disabled and will not be generated. 1: overflow/underflow event is enabled and will be generated for every counter overflow/underflow. this bit is not enable-protected. z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 5 ? tcei: tc event input this bit is used to enable input events to the tc. 0: incoming events are disabled. 1: incoming events are enabled. this bit is not enable-protected. bit151413121110 9 8 mceo1 mceo0 ovfeo access r r r/w r/w r r r r/w reset00000000 bit76543210 tcei tcinv evact[2:0] access r r r/w r/w r r/w r/w r/w reset00000000
462 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 4 ? tcinv: tc inverted event input this bit inverts the input event source when used in pwp or ppw measurement. 0: input event source is not inverted. 1: input event source is inverted. this bit is not enable-protected. z bit 3 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 2:0 ? evact[2:0]: event action these bits define the event action the tc will perform on an event,as shown in table 27-10 . table 27-10. event action value name description 0x0 off event action disabled 0x1 retrigger start, restart or retrigger tc on event 0x2 count count on event 0x3 start start tc on event 0x4 - reserved 0x5 ppw period captured in cc0, pulse width in cc1 0x6 pwp period captured in cc1, pulse width in cc0 0x7 - reserved
463 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.8 interrupt enable clear this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x0c reset: 0x00 property: write-protected z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:4 ? mcx: match or capt ure channel x interrupt enable 0: the match or capture channel x interrupt is disabled. 1: the match or capture channel x interrupt is enabled. writing a zero to mcx has no effect. writing a one to mcx will clear the corresponding match or capture channel x interrupt disable/enable bit, which disables the match or capture channel x interrupt. z bit 3 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization read y interrupt disable/enable bit, which disables the syn- chronization ready interrupt. z bit 2 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 1 ? err: error interrupt enable 0: the error interrupt is disabled. 1: the error interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the error interrupt disable/enable bit, which disables the error interrupt. z bit 0 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the overflow interrupt disable/enable bit, which disables the overflow interrupt. bit76543210 mc1 mc0 syncrdy err ovf access r r/w r/w r/w r/w r r/w r/w reset00000000
464 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.9 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x0d reset: 0x00 property: write-protected z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:4 ? mcx: match or capt ure channel x interrupt enable 0: the match or capture channel x interrupt is disabled. 1: the match or capture channel x interrupt is enabled. writing a zero to mcx has no effect. writing a one to mcx will set the corresponding match or capture channel x interrupt enable bit, which enables the match or capture channel x interrupt. z bit 3 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the synchronization ready interrupt disable/enable bit, which enables the syn- chronization ready interrupt. z bit 2 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 1 ? err: error interrupt enable 0: the error interrupt is disabled. 1: the error interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the error interrupt bit, which enables the error interrupt. z bit 0 ? ovf: overflow interrupt enable 0: the overflow interrupt is disabled. 1: the overflow interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the overflow interrupt enable bit, which enables the overflow interrupt. bit76543210 mc1 mc0 syncrdy err ovf access r r r/w r/w r/w r r/w r/w reset00000000
465 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.10 interrupt flag status and clear name: intflag offset: 0x0e reset: 0x00 property: - z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:4 ? mcx: match or capture channel x this flag is set on the next clk_tc_cnt cycle after a match with the compare condition or once ccx register contain a valid capture value, and will generate an interrupt request if the corresponding match or capture chan- nel x interrupt enable bit in the interrupt enable set register (intenset.mcx) is one. writing a zero to one of these bits has no effect. writing a one to one of these bits will clear the corresponding match or capture channel x interrupt flag in capture mode, this flag is automatically cleared when ccx register is read. z bit 3 ? syncrdy: synchronization ready this flag is set on a 1-to-0 transition of the synchroniza tion busy bit in the status register (status.syncbusy), except when the transition is caused by an enable or software reset, and will generate an interrupt request if the synchronization ready interrupt enable bit in the inte rrupt enable set register (intenset.syncrdy) is one. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization ready interrupt flag z bit 2 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bit 1 ? err: error this flag is set if a new capture occurs on a channel when the corresponding match or capture channel x interrupt flag is one, in which case there is nowhere to store the new capture. writing a zero to this bit has no effect. writing a one to this bit clears the error interrupt flag. z bit 0 ? ovf: overflow this flag is set on the next clk_tc_cnt cycle after an overflow condition occurs, and will generate an interrupt if intenclr/set.ovf is one. writing a zero to this bit has no effect. writing a one to this bit clears the overflow interrupt flag. bit 7 6 5 4 3 2 1 0 mc1 mc0 syncrdy err ovf access r r r/w r/w r/w r r/w r/w reset 0 0 0 0 0 0 0 0
466 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.11 status name: status offset: 0x0f reset: 0x08 property: - z bit 7 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? slave: slave this bit is set when the even-numbered master tc is se t to run in 32-bit mode. the odd-numbered tc will be the slave. z bit 3 ? stop: stop this bit is set when the tc is disabled, on a stop command or on an overflow or underflow condition when the one-shot bit in the control b set register (ctrlbset.oneshot) is one. 0: counter is running. 1: counter is stopped. z bits 2:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit76543210 syncbusy slave stop accessrrrrrrrr reset00001000
467 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.12 counter value 27.8.12.1 8-bit mode name: count offset: 0x10 reset: 0x00 property: write-synchronized, read-synchronized z bits 7:0 ? count[7:0]: counter value these bits contain the current counter value. bit76543210 count[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
468 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.12.2 16-bit mode name: count offset: 0x10 reset: 0x0000 property: write-synchronized, read-synchronized z bits 15:0 ? count[15:0]: counter value these bits contain the current counter value. bit151413121110 9 8 count[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 count[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
469 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.12.3 32-bit mode name: count offset: 0x10 reset: 0x00000000 property: write-synchronized, read-synchronized z bits 31:0 ? count[31:0]: counter value these bits contain the current counter value. bit3130292827262524 count[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 count[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit2322212019181716 count[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 count[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
470 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.13 period value the period value register is available only in 8-bit tc mode. it is not available in 16-bit and 32-bit tc modes. 27.8.13.1 8-bit mode name: per offset: 0x14 reset: 0xff property: write-synchronized, read-synchronized z bits 7:0 ? per[7:0]: period value these bits contain the counter period value in 8-bittc mode. bit76543210 per[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset11111111
471 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.14 compare/capture 27.8.14.1 8-bit mode name: ccx offset: 0x18+i*0x1 [i=0..3] reset: 0x00 property: write-synchronized, read-synchronized z bits 7:0 ? cc[7:0]: compare/capture value these bits contain the compare/capture value in 8-bi t tc mode. in frequency or pwm waveform match operation (ctrla.wavegen), the cc0 register is used as a period register. bit76543210 cc[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
472 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.14.2 16-bit mode name: ccx offset: 0x18+i*0x2 [i=0..3] reset: 0x0000 property: write-synchronized, read-synchronized z bits 15:0 ? cc[15:0]: compare/capture value these bits contain the compare/capture value in 16-bi t tc mode. in frequency or pwm waveform match operation (ctrla.wavegen), the cc0 register is used as a period register. bit151413121110 9 8 cc[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 cc[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
473 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.8.14.3 32-bit mode name: ccx offset: 0x18+i*0x4 [i=0..3] reset: 0x00000000 property: write-synchronized, read-synchronized z bits 31:0 ? cc[31:0]: compare/capture value these bits contain the compare/capture value in 32- bit tc mode. in frequency or pwm waveform match opera- tion (ctrla.wavegen), the cc0 regist er is used as a period register. bit3130292827262524 cc[31:24] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit2322212019181716 cc[23:16] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit151413121110 9 8 cc[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 cc[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
474 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28. adc ? analog-to-digital converter 28.1 overview the analog-to-digital converter (adc) converts analog signals to digital values. the adc has 12-bit resolution, and is capable of converting up to 350ksps. the input selection is flexible, and both differential and single-ended measurements can be performed. an optional gain stage is available to incr ease the dynamic range. in addition, several internal signal inputs are available. the adc can provide both signed and unsigned results. adc measurements can be started by either application softwa re or an incoming event from another peripheral in the device. adc measurements can be started with predictable timing, and without software intervention. both internal and external reference voltages can be used. an integrated temperature sensor is available for use with the adc. the bandgap voltage as well as the scaled i/o and core voltages can also be measured by the adc. the adc has a compare function for accurate monitoring of user-defined thresholds, with minimum software intervention required. the adc may be configured for 8-, 10- or 12-bit results, reducing the conversion time. adc conversion results are provided left- or right-adjusted, which eases calculat ion when the result is represented as a signed value. 28.2 features z 8-, 10- or 12-bit resolution z up to 350,000 samples per second (350ksps) z differential and single-ended inputs z up to 32 analog inputs z 25 positive and 10 negative, including internal and external z five internal inputs z bandgap z temperature sensor z dac z scaled core supply z scaled i/o supply z 1/2x to 16x gain z single, continuous and pin-scan conversion options z windowing monitor with selectable channel z conversion range: z v ref [1v to v ddana - 0.6v] z adcx * gain [0v to -v ref ] z built-in internal reference and external reference options z four bits for reference selection
475 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z event-triggered conversion for accurate timing (one event input) z hardware gain and offset compensation z averaging and oversampling with decimation to support, up to 16-bit result z selectable sampling time 28.3 block diagram figure 28-1. adc block diagram 28.4 signal description note: 1. refer to ?configuration summary? on page 3 for details on exact number of analog input channels. refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. adc adc0 adcn ... int.sig adc0 adcn int.sig ... refctrl int1v intvcc vrefb offsetcorr gaincorr swtrig evctrl avgctrl winctrl sampctrl winut post processing prescaler ctrla winlt vrefa ctrlb result inputctrl signal name type description vrefa analog input external reference voltage a vrefb analog input external reference voltage b adc[19..0] (1) analog input analog input channels
476 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 28.5.1 i/o lines using the adc's i/o lines requires the i/o pins to be configured using the port configuration (port). refer to ?port? on page 280 for details. 28.5.2 power management the adc will continue to operate in any sleep mode where the selected source clock is running. the adc?s interrupts can be used to wake up the device from sleep modes. the events can trigger other operations in the system without exiting the sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 28.5.3 clocks the adc bus clock (clk_adc_apb) can be enabled and dis abled in the power manager, and the default state of clk_adc_apb can be found in the table 15-1 . a generic clock (gclk_adc) is required to clock the adc. this clock must be configured and enabled in the generic clock controller (gclk) before using the adc. refer ?gclk ? generic clock controller? on page 79 for details. this generic clock is asynchronous to the bus clock (clk_a dc_apb). due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 484 for further details. 28.5.4 dma not applicable. 28.5.5 interrupts the interrupt request line is connected to the interrupt controlle r. using adc interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 28.5.6 events events are connected to the event system. refer to ?evsys ? event system? on page 306 for details. 28.5.7 debug operation when the cpu is halted in debug mode, the adc will halt normal operation. the adc can be forced to continue operation during debugging. refer to the debug control register ( dbgctrl ) for details. 28.5.8 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following register: z interrupt flag status and clear register ( intflag ) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode or the cpu reset is extended, all write-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 28.5.9 analog connections i/o-pins ain0 to ain19 as well as the arefa/arefb reference voltage pin are analog inputs to the adc.
477 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.5.10 calibration the values bias_cal and linearity_cal from the production test must be loaded from the nvm software calibration area into the adc calibration register (calib) by software to achieve specified accuracy. refer to ?nvm software calibration area mapping? on page 23 for more details. 28.6 functional description 28.6.1 principle of operation by default, the adc provides results with 12-bit resolution. 8- bit or 10-bit results can be selected in order to reduce the conversion time. the adc has an oversampling with decimation option that can extend the resolution to 16 bits. the input values can be either internal (e.g., internal temperatur e sensor) or external (connected i/o pins). the user can also configure whether the conversion should be single-ended or differential. 28.6.2 basic operation 28.6.2.1 initialization before enabling the adc, the asynchronous clock source must be selected and enabled, and the adc reference must be configured. the first conversion after the reference is changed must not be used. all other configuration registers must be stable during the conversion. the source for gclk_adc is selected and enabled in the system controller (sysctrl). refer to ?sysctrl ? system controller? on page 128 for more details. when gclk_adc is enabled, the adc can be enabled by writi ng a one to the enable bit in the control register a (ctrla.enable). 28.6.2.2 enabling, disabling and reset the adc is enabled by writing a one to the enable bit in t he control a register (ctrla.e nable). the adc is disabled by writing a zero to ctrla.enable. the adc is reset by writing a one to the software reset bit in the control a register (ctrla.s wrst). all registers in the adc, except dbgctrl, will be reset to their initial state, and the adc will be disabled. refer to the ctrla register for details. the adc must be disabled before it is reset. 28.6.2.3 basic operation in the most basic configuration, the adc sample values from the configured internal or external sources ( inputctrl register). the rate of the conversion is dependent on the combination of the gclk_adc frequency and the clock prescaler. to convert analog values to digital values, the adc needs first to be initialized, as described in ?initialization? on page 477 . data conversion can be started either manually, by writing a one to the start bit in the software trigger register (swtrig.start), or automatically, by c onfiguring an automatic trigger to initia te the conversions. a free-running mode could be used to continuously convert an input channel. there is no need for a trigger to start the conversion. it will start automatically at the end of previous conversion. the automatic trigger can be configured to trigger on many different conditions. the result of the conversion is stored in the result register ( result ) as it becomes available, overwriting the result from the previous conversion. to avoid data loss if more than one channel is enabled, the conversion result must be read as it becomes available (intflag.resrdy). failing to do so will result in an overr un error condition, indicated by the overrun bit in the interrupt flag status and clear register (intflag.overrun). to use an interrupt handler, the corresponding bit in the inte rrupt enable set register (int enset) must be written to one.
478 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.6.3 prescaler the adc is clocked by gclk_adc. there is also a presca ler in the adc to enable conversion at lower clock rates. refer to ctrlb for details on prescaler settings. figure 28-2. adc prescaler the propagation delay of an adc measurement is given by: 28.6.4 adc resolution the adc supports 8-bit, 10-bit and 12-bit resolutions. resolu tion can be changed by writing the resolution bit group in the control b register (ctrlb.ressel). after a reset, the resolution is set to 12 bits by default. table 28-1. delay gain intputctrl.gain[3:0] delay gain (in clk_adc period) differential mode single-ended mode 0x0 0 0 0x1 0 1 0x2 1 1 0x3 1 2 0x4 2 2 0x5 ... 0xe reserved reserved 0xf 0 1 gclk_adc 9-bit prescaler ctrlb.prescaler[2:0] div512 div256 div128 div64 div32 div16 div8 div4 clk_adc propagationdelay 1 resolution 2 ---------------------------- delaygain ++ f clk adc ? ------------------------------------------------------------------------- - =
479 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.6.5 differential and single-ended conversions the adc has two conversion options: differential and single- ended. when measuring signals where the positive input is always at a higher voltage than the negative input, the single-ended conversion should be used in order to have full 12- bit resolution in the conversion, which has only positive values. the negative input must be connected to ground. this ground could be the internal gnd, iognd or an external ground connected to a pin. refer to inputctrl for selection details. if the positive input may go below the negative input, creating some negative results, the differential mode should be used in order to get correct results. the configuration of the conversion is done in the differential mode bit in the control b register (ctrlb.diffmode). these two types of conversion could be run in single mode or in free-running mode. when set up in free-running mode, an adc input will continuously sample and do new conversions. the intflag.resrdy bit will be set at the end of each conversion. 28.6.5.1 conversion timing figure 28-3 shows the adc timing for a single conversion without gain. the writing of the adc start conversion bit (swtrig.start) or start conversion event in bit (evctr l.startei) must occur at least one clk_adc_apb cycle before the clk_adc cycle on which the conversion starts. the input channel is sampled in the first half clk_adc period. the sampling time can be increased by using the sa mpling time length bit group in the sampling time control register (sampctrl.samplen). refer to figure 28-4 for example on increased sampling time. figure 28-3. adc timing for one conversi on in differential mode without gain figure 28-4. adc timing for one conver sion in differential mode without ga in, but with incre ased sampling time 12345678 clk_ adc start sample int converting bit msb10987654321lsb 12345678 clk_ adc start sample int converting bit msb10987654321lsb 91011
480 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 28-5. adc timing for free runni ng in differential mode without gain figure 28-6. adc timing for one conversi on in single-ended mode without gain figure 28-7. adc timing for free runni ng in single-ended mode without gain 1 2345678 clk_ adc start sample int converting bit 91011 12 13 14 15 16 11109876543210 11 1098765432101110 98765 12345678 clk_ adc start sample int conver ting bit 91011 amplify msb10987654321lsb 1 2345678 clk_ adc start sample int converting bit 91011 12 13 14 15 16 11109876543210 11 109876543210 1110 amplify
481 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.6.6 accumulation the result from multiple consecutive conversions can be accumulated. the number of samples to be accumulated is specified by writing to the number of samples to be collected field in the average control register (avgctrl.samplenum) as described in table 28-2 . when accumulating more than 16 samples, the result will be too large for the 16-bit result register. to avoid overflow, the result is shifted right automatically to fit within the 16 available bits. the number of automatic right shifts are specified in table 28-2 . note that to be able to perform the accumulation of two or more samples, the conversion result resolution field in the contro l b register (ctrlb.ressel) must be written to one. table 28-2. accumulation 28.6.7 averaging averaging is a feature that increases the sample accuracy, though at the cost of reduced sample rate. this feature is suitable when operating in noisy conditions. averaging is done by accumulating m samples, as described in ?accumulation? on page 481 , and divide the result by m . the averaged result is available in the result register. the number of samples to be accumulated is specified by writing to avgctrl.samplenum as described in table 28-3 . the division is obtained by a combination of the automatic right shift described above, and an additional right shift that must be specified by writing to the adjusting result/div ision coefficient field in avgctrl (avgctrl.adjres) as described in table 28-3 . note that to be able to perform the averaging of two or more samples, the conversion result resolution field in the control b register (ctrlb.ressel) must be written to one. averaging avgctrl.samplenum samples will reduce the effective sample rate by . when the required average is reached, the intflag.resrdy bit is set. number of accumulated samples avgctrl. samplenum intermediate result precision number of automatic right shifts final result precision automatic division factor 1 0x0 12 bits 0 12 bits 0 2 0x1 13 bits 0 13 bits 0 4 0x2 14 bits 0 14 bits 0 8 0x3 15 bits 0 15 bits 0 16 0x4 16 bits 0 16 bits 0 32 0x5 17 bits 1 16 bits 2 64 0x6 18 bits 2 16 bits 4 128 0x7 19 bits 3 16 bits 8 256 0x8 20 bits 4 16 bits 16 512 0x9 21 bits 5 16 bits 32 1024 0xa 22 bits 6 16 bits 64 reserved 0xb ?0xf 12 bits 12 bits 0 1 avgctrl.samplenum -------------------------------------------------------------------
482 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 28-3. averaging 28.6.8 oversampling and decimation by using oversampling and decimation, the adc resolution c an be increased from 12 bits to up to 16 bits. to increase the resolution by n bits, 4 n samples must be accumulated. the result must then be shifted right by n bits. this right shift is a combination of the automatic right shift and the value wri tten to avgctrl.adjres. to obtain the correct resolution, the adjres must be configured as described in the table below. this method will result in n bit extra lsb resolution. table 28-4. configuration required for oversampling and decimation 28.6.9 window monitor the window monitor allows the conversion result to be compared to some predefined threshold values. supported modes are selected by writing the window monitor m ode bit group in the window monitor control register (winctrl.winmode[2:0]). thresholds are given by writing the window monitor lower threshold register (winlt) and window monitor upper thre shold register (winut). if differential input is selected, the winlt and winut are evaluated as signed values. otherwise they are evaluated as unsigned values. number of accumulated samples avgctrl. samplenum intermediate result precision number of automatic right shifts division factor avgctrl. adjres total number of right shifts final result precision automatic division factor 1 0x0 12 bits 0 1 0x0 12 bits 0 2 0x1 13 0 2 0x1 1 12 bits 0 4 0x2 14 0 4 0x2 2 12 bits 0 8 0x3 15 0 8 0x3 3 12 bits 0 16 0x4 16 0 16 0x4 4 12 bits 0 32 0x5 17 1 16 0x4 5 12 bits 2 64 0x6 18 2 16 0x4 6 12 bits 4 128 0x7 19 3 16 0x4 7 12 bits 8 256 0x8 20 4 16 0x4 8 12 bits 16 512 0x9 21 5 16 0x4 9 12 bits 32 1024 0xa 22 6 16 0x4 10 12 bits 64 reserved 0xb ?0xf 0x0 12 bits 0 result resolution number of samples to average avgctrl.samplenum[3:0] number of automatic right shifts avgctrl.adjres[2:0] 13 bits 4 1 = 4 0x2 0 0x1 14 bits 4 2 = 16 0x4 0 0x2 15 bits 4 3 = 64 0x6 2 0x1 16 bits 4 4 = 256 0x8 4 0x0
483 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 another important point is that the significant winlt and winut bits are given by the precision selected in the conversion result resolution bit group in the control b regi ster (ctrlb.ressel). this means that if 8-bit mode is selected, only the eight lower bits will be considered. in additi on, in differential mode, the eighth bit will be considered as the sign bit even if the ninth bit is zero. the intflag.winmon interrupt flag will be set if the c onversion result matches the window monitor condition. 28.6.10 offset and gain correction inherent gain and offset errors affect the absolute accuracy of the adc. the offset error is defined as the deviation of the actual adc?s transfer function from an ideal straight line at zero input voltage. the offset error cancellation is handled by the offset correction register (offsetcorr). the offset co rrection value is subtracted from the converted data before writing the result register (result). t he gain error is defined as the deviation of the last output step?s midpoint from the ideal straight line, after compensating for offset error. the gain error cancellation is handled by the gain correction register (gaincorr). to correct these two errors, the digi tal correction logic enabled bit in the control b register (ctrlb.corren) must be written to one. offset and gain error compensation results are both calculated according to: in single conversion, a latency of 13 gclk_adc is added to the av ailability of the final result. since the correction time is always less than the propagation delay, this latency appears in free-running mode only during the first conversion. after that, a new conversion will be initialized when a conversion co mpletes. all other conversion results are available at the defined sampling rate. figure 28-8. adc timing correction enabled 28.6.11 interrupts the adc has the following interrupt sources: z result conversion ready: resrdy z overrun: overrun z window monitor: winmon z synchronization ready: syncrdy result conversion value offsetcorr ? () gaincorr ? = start conv0 conv1 conv2 conv3 corr0 corr1 corr2 corr3
484 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr) register. an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the peripheral is reset. an interrupt flag is cleared by writing a one to the corresponding bit in the intflag register. each peripheral can have one interrupt request line per interrupt source or one common interrupt request line for all the interrupt sources. this is device dependent. refer to ?nested vector interrupt controller? on page 25 for details. if the peripheral has one common interrupt request line for all the interrupt sources, the user must read the intflag register to determine which interrupt condition is present. 28.6.12 events the peripheral can generate the following output events: z result ready (resrdy) z window monitor (winmon) output events must be enabled to be generated. writing a one to an event output bit in the event control register (evctrl.xxeo) enables the corresponding output event. writing a zero to this bit disables the corresponding output event. the events must be correctly routed in the event system. refer to ?evsys ? event system? on page 306 for details. the peripheral can take the following actions on an input event: z adc start conversion (start) z adc conversion flush (flush) input events must be enabled for the corresponding action to be taken on any input event. writing a one to an event input bit in the event control register (evctrl.xxei) enabl es the corresponding action on the input event. writing a zero to this bit disables the corresponding action on the input event. note that if several events are connected to the peripheral, the enabled action will be taken on any of the inco ming events. the events must be correctly routed in the event system. refer to ?evsys ? event system? on page 306 for details. 28.6.13 sleep mode operation the run in standby bit in the control a register (ctrla .runstdby) controls the behavior of the adc during standby sleep mode. when the bit is zero, the adc is disabled during sleep, but maintains its current configuration. when the bit is one, the adc continues to operate during sleep. note that when runstdby is zero, the analog blocks are powered off for the lowest power consumption. this necessitates a start-up time delay when the system returns from sleep. when runstdby is one, any enabled adc interrupt source can wake up the cpu. while the cpu is sleeping, adc conversion can only be triggered by events. 28.6.14 synchronization due to the asynchronicity between clk_adc_apb and gc lk_adc, some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. the synchronization ready interrupt can be used to signal when synchronization is complete.
485 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in the control a register (ctrla.swrst) z enable bit in the control a register (ctrla.enable) the following registers need synchronization when written: z control b (ctrlb) z software trigger (swtrig) z window monitor control (winctrl) z input control (inputctrl) z window upper/lower threshold (winut/winlt) write-synchronization is denoted by the write-synchronized property in the register description. the following registers need synchronization when read: z software trigger (swtrig) z input control (inputctrl) z result (result) read-synchronization is denoted by the read-synchronized property in the register description.
486 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.7 register summary offset name bit pos. 0x00 ctrla 7:0 runstdby enable swrst 0x01 refctrl 7:0 refcomp refsel[3:0] 0x02 avgctrl 7:0 adjres[2:0] samplenum[3:0] 0x03 sampctrl 7:0 samplen[5:0] 0x04 ctrlb 7:0 ressel[1:0] corren freerun leftadj diffmode 0x05 15:8 prescaler[2:0] 0x06 reserved 0x07 reserved 0x08 winctrl 7:0 winmode[2:0] 0x09 reserved 0x0a reserved 0x0b reserved 0x0c swtrig 7:0 start flush 0x0d reserved 0x0e reserved 0x0f reserved 0x10 inputctrl 7:0 muxpos[4:0] 0x11 15:8 muxneg[4:0] 0x12 23:16 inputoffset[3:0] inputscan[3:0] 0x13 31:24 gain[3:0] 0x14 evctrl 7:0 winmoneo resrdyeo syncei startei 0x15 reserved 0x16 intenclr 7:0 syncrdy winmon overrun resrdy 0x17 intenset 7:0 syncrdy winmon overrun resrdy 0x18 intflag 7:0 syncrdy winmon overrun resrdy 0x19 status 7:0 syncbusy 0x1a result 7:0 result[7:0] 0x1b 15:8 result[15:8] 0x1c winlt 7:0 winlt[7:0] 0x1d 15:8 winlt[15:8] 0x1e reserved 0x1f reserved 0x20 winut 7:0 winut[7:0] 0x21 15:8 winut[15:8] 0x22 reserved 0x23 reserved
487 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x24 gaincorr 7:0 gaincorr[7:0] 0x25 15:8 gaincorr[11:8] 0x26 offsetcorr 7:0 offsetcorr[7:0] 0x27 15:8 offsetcorr[11:8] 0x28 calib 7:0 linearity_cal[7:0] 0x29 15:8 bias_cal[2:0] 0x2a dbgctrl 7:0 dbgrun offset name bit pos.
488 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 476 for details. some registers require synchronization when read and/or wr itten. synchronization is denoted by the write-synchronized or the read-synchronized property in each individual register description. refer to ?synchronization? on page 484 for details. some registers are enable-protected, meaning they can be wr itten only when the adc is disabled. enable-protection is denoted by the enable-protected property in each individual register description. 28.8.1 control a name: ctrla offset: 0x00 reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? runstdby: run in standby this bit indicates whether the adc will continue running in standby sleep mode or not: 0: the adc is halted during standby sleep mode. 1: the adc continues normal operation during standby sleep mode. z bit 1 ? enable: enable 0: the adc is disabled. 1: the adc is enabled. due to synchronization, there is a del ay from writing ctrla.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbusy will be cleared when the operation is complete. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the adc, except dbgctrl, to their initial state, and the adc will be disabled. bit 76543210 runstdby enable swrst accessrrrrrr/wr/wr/w reset00000000
489 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete.
490 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.2 reference control name: refctrl offset: 0x01 reset: 0x00 property: write-protected z bit 7 ? refcomp: reference buff er offset compensation enable the accuracy of the gain stage can be increased by enabling the reference buffer offset compensation. this will decrease the input impedance and thus increase the start-up time of the reference. 0: reference buffer offset compensation is disabled. 1: reference buffer offset compensation is enabled. z bits 6:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 3:0 ? refsel[3:0]: reference selection these bits select the reference for the adc according to table 28-5 . table 28-5. reference selection bit 76543210 refcomp refsel[3:0] access r/w r r r r/w r/w r/w r/w reset00000000 value name description 0x0 int1v 1.0v voltage reference 0x1 intvcc0 1/1.48 v ddana 0x2 intvcc1 1/2 v ddana (only for v ddana > 2.0v) 0x3 arefa external reference 0x4 arefb external reference 0x5-0xf reserved reserved
491 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.3 average control name: avgctrl offset: 0x02 reset: 0x00 property: write-protected z bit 7 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 6:4 ? adjres[2:0]: adjustin g result / division coefficient these bits define the division coefficient in 2 n steps. z bits 3:0 ? samplenum[3:0]: number of samples to be collected these bits define how many samples should be added together.the result will be available in the result register (result). note: if the result width increases, ctrlb.ressel must be changed. table 28-6. number of samples to be collected bit 76543210 adjres[2:0] samplenum[3:0] access r r/w r/w r/w r/w r/w r/w r/w reset00000000 value name description 0x0 1 sample 0x1 2 samples 0x2 4 samples 0x3 8 samples 0x4 16 samples 0x5 32 samples 0x6 64 samples 0x7 128 samples 0x8 256 samples 0x9 512 samples 0xa 1024 samples 0xb-0xf reserved
492 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.4 sampling time control name: sampctrl offset: 0x03 reset: 0x00 property: write-protected z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:0 ? samplen[5:0]: sampling time length these bits control the adc sampling time in number of half clk_adc cycles, depending of the prescaler value, thus controlling the adc input impedance. sampling time is set according to the equation: bit 76543210 samplen[5:0] access r r r/w r/w r/w r/w r/w r/w reset00000000 sampling time samplen 1 + () clk adc 2 ---------------------- ?? ?? ? =
493 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.5 control b name: ctrlb offset: 0x04 reset: 0x0000 property: write-synchronized, write-protected z bits 15:11 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 10:8 ? prescaler[2:0]: prescaler configuration these bits define the adc clock relative to the peripheral clock according to table 28-7 . these bits can only be written while the adc is disabled. table 28-7. prescaler configuration z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:4 ? ressel[1:0]: co nversion result resolution these bits define whether the adc completes the conversion at 12-, 10- or 8-bit result resolution. these bits can be written only while the adc is disabled. bit 151413121110 9 8 prescaler[2:0] accessrrrrrr/wr/wr/w reset00000000 bit76543210 ressel[1:0] corren freerun leftadj diffmode access r r r/w r/w r/w r/w r/w r/w reset00000000 value name description 0x0 div4 peripheral clock divided by 4 0x1 div8 peripheral clock divided by 8 0x2 div16 peripheral clock divided by 16 0x3 div32 peripheral clock divided by 32 0x4 div64 peripheral clock divided by 64 0x5 div128 peripheral clock divided by 128 0x6 div256 peripheral clock divided by 256 0x7 div512 peripheral clock divided by 512
494 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 28-8. conversion result resolution z bit 3 ? corren: digital correction logic enabled 0: disable the digital result correction. 1: enable the digital result correction. the adc conversion re sult in the result register is then corrected for gain and offset based on the values in the gaincal and offs etcal registers. conversion time will be increased by x cycles according to the value in the offset correc tion value bit group in the offset correction register. this bit can be changed only while the adc is disabled. z bit 2 ? freerun: free running mode 0: the adc run is single conversion mode. 1: the adc is in free running mode and a new conversion wi ll be initiated when a previous conversion completes. this bit can be changed only while the adc is disabled. z bit 1 ? leftadj: left-adjusted result 0: the adc conversion result is right-adjusted in the result register. 1: the adc conversion result is left-adjusted in the result register. the high byte of the 12-bit result will be present in the upper part of the result register. writing this bit to zero (default) will right-adjust the value in the result register. this bit can be changed only while the adc is disabled. z bit 0 ? diffmode: differential mode 0: the adc is running in singled-ended mode. 1: the adc is running in differential mode. in this mode, the voltage difference between the muxpos and mux- neg inputs will be converted by the adc. this bit can be changed only while the adc is disabled. value name description 0x0 12bit 12-bit result 0x1 16bit for averaging mode output 0x2 10bit 10-bit result 0x3 8bit 8-bit result
495 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.6 window monitor control name: winctrl offset: 0x08 reset: 0x00 property: write-synchronized, write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:0 ? winmode[2:0]: window monitor mode these bits enable and define the window monitor mode. table 28-9 shows the mode selections. table 28-9. window monitor mode bit 76543210 winmode[2:0] accessrrrrrr/wr/wr/w reset00000000 value name description 0x0 no window mode (default) 0x1 mode 1: result > winlt 0x2 mode 2: result < winut 0x3 mode 3: winlt < result < winut 0x4 mode 4:!(winlt < result < winut) 0x5-0x7 reserved
496 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.7 software trigger name: swtrig offset: 0x0c reset: 0x00 property: write-synchronized, write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? start: adc start conversion 0: the adc will not start a conversion. 1: the adc will start a conversion. the bit is cleared by hardware when the conversion has started. setting this bit when it is already set has no effect. writing this bit to zero will have no effect. z bit 0 ? flush: adc conversion flush 0: no flush action. 1: the adc pipeline will be flushed. a flush will restar t the adc clock on the next peripheral clock edge, and all conversions in progress will be aborted and lost. this bit is cleared until the adc has been flushed. after the flush, the adc will resume where it left off; i.e., if a conversion was pending, the adc will start a new conversion. writing this bit to zero will have no effect. bit76543210 start flush accessrrrrrrr/wr/w reset00000000
497 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.8 input control name: inputctrl offset: 0x10 reset: 0x00000000 property: write-synchronized, write-protected z bits 31:28 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 27:24 ? gain[3:0]: gain factor selection these bits set the gain factor of the adc gain stage according to the values shown in table 28-10 . bit3130292827262524 gain[3:0] accessrrrrr/wr/wr/wr/w reset00000000 bit2322212019181716 inputoffset[3:0] inputscan[3:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000 bit151413121110 9 8 muxneg[4:0] access r r r r/w r/w r/w r/w r/w reset00000000 bit76543210 muxpos[4:0] access r r r r/w r/w r/w r/w r/w reset00000000
498 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 23:20 ? inputoffset[3:0] : positive mux setting offset the pin scan is enabled when inputscan != 0. writing these bits to a value other than zero causes the first con- version triggered to be converted using a positive input equal to muxpos + inputoffset. setting this register to zero causes the first conversion to use a positive input equal to muxpos. after a conversion, the inputoffset register will be incremented by one, causing the next conversion to be done with the positive input equal to muxpos + inputo ffset. the sum of muxp os and inputoffset gives the input that is actually converted. z bits 19:16 ? inputscan[3:0]: number of input channels included in scan this register gives the number of input sources included in the pin scan. the number of input sources included is inputscan + 1. the input channels included are in t he range from muxpos + in putoffset to muxpos + inputoffset + inputscan. the range of the scan mode must not exceed the number of input channels available on the device. z bits 15:13 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 12:8 ? muxneg[4:0]: negative mux input selection these bits define the mux selection for the negative adc input. table 28-11 shows the possible input selections. table 28-10. gain factor selection value name description 0x0 1x 1x 0x1 2x 2x 0x2 4x 4x 0x3 8x 8x 0x4 16x 16x 0x5-0xe ? reserved 0xf div2 1/2x table 28-11. negative mux input selection value name description 0x00 pin0 adc ain0 pin 0x01 pin1 adc ain1 pin
499 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 4:0 ? muxpos[4:0]: positive mux input selection these bits define the mux selection for the positive adc input. table 28-12 shows the possible input selections. if the internal bandgap voltage or temperature sensor input channel is selected, then the sampling time length bit group in the sampling control register must be written with a corresponding value. 0x02 pin2 adc ain2 pin 0x03 pin3 adc ain3 pin 0x04 pin4 adc ain4 pin 0x05 pin5 adc ain5 pin 0x06 pin6 adc ain6 pin 0x07 pin7 adc ain7 pin 0x08-0x17 ? reserved 0x18 gnd internal ground 0x19 iognd i/o ground 0x1a-0x1f ? reserved table 28-12. positive mux input selection muxpos[4:0] group configuration description 0x00 pin0 adc ain0 pin 0x01 pin1 adc ain1 pin 0x02 pin2 adc ain2 pin 0x03 pin3 adc ain3 pin 0x04 pin4 adc ain4 pin 0x05 pin5 adc ain5 pin 0x06 pin6 adc ain6 pin 0x07 pin7 adc ain7 pin 0x08 pin8 adc ain8 pin 0x09 pin9 adc ain9 pin 0x0a pin10 adc ain10 pin 0x0b pin11 adc ain11 pin 0x0c pin12 adc ain12 pin 0x0d pin13 adc ain13 pin table 28-11. negative mux input selection (continued) value name description
500 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 0x0e pin14 adc ain14 pin 0x0f pin15 adc ain15 pin 0x10 pin16 adc ain16 pin 0x11 pin17 adc ain17 pin 0x12 pin18 adc ain18 pin 0x13 pin19 adc ain19 pin 0x14-0x17 reserved 0x18 temp temperature reference 0x19 bandgap bandgap voltage 0x1a scaledcorevcc 1/4 scaled core supply 0x1b scalediovcc 1/4 scaled i/o supply 0x1c dac dac output 0x1d-0x1f reserved table 28-12. positive mux input selection (continued) muxpos[4:0] group configuration description
501 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.9 event control name: evctrl offset: 0x14 reset: 0x00 property: write-protected z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 5 ? winmoneo: window monitor event out this bit indicates whether the window monitor event output is enabled or not and an output event will be gener- ated when the window monitor detects something. 0: window monitor event output is disabled and an event will not be generated. 1: window monitor event output is enabled and an event will be generated. z bit 4 ? resrdyeo: result ready event out this bit indicates whether the result ready event output is enabled or not and an output event will be generated when the conversion result is available. 0: result ready event output is disabled and an event will not be generated. 1: result ready event output is enabled and an event will be generated. z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? syncei: synchronization event in 0: a flush and new conversion will not be triggered on any incoming event. 1: a flush and new conversion will be triggered on any incoming event. z bit 0 ? startei: start conversion event in 0: a new conversion will not be triggered on any incoming event. 1: a new conversion will be triggered on any incoming event. bit76 5 43210 winmoneo resrdyeo syncei startei access r r r/w r/w r r r/w r/w reset00 0 00000
502 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.10 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x16 reset: 0x00 property: write-protected z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled, and an interrupt request will be generated when the synchroni- zation ready interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization ready interrupt enable bit and the corresponding interrupt request. z bit 2 ? winmon: window monitor interrupt enable 0: the window monitor interrupt is disabled. 1: the window monitor interrupt is enabled, and an interrupt request will be generated when the window monitor interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the window monitor in terrupt enable bit and the corresponding interrupt request. z bit 1 ? overrun: overrun interrupt enable 0: the overrun interrupt is disabled. 1: the overrun interrupt is enabled, and an interrupt request will be generated when the overrun interrupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the overrun interrupt enable bit and the corresponding interrupt request. z bit 0 ? resrdy: result ready interrupt enable 0: the result ready interrupt is disabled. 1: the result ready interrupt is enabled, and an interrupt request will be generated when the result ready inter- rupt flag is set. writing a zero to this bit has no effect. writing a one to this bit will clear the result ready interrupt enable bit and the corresponding interrupt request. bit76543210 syncrdy winmon overrun resrdy access r r r r r/w r/w r/w r/w reset00000000
503 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.11 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x17 reset: 0x00 property: write-protected z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the synchronization ready interrupt enable bit, which enables the synchronization ready interrupt. z bit 2 ? winmon: window monitor interrupt enable 0: the window monitor interrupt is disabled. 1: the window monitor interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the window monitor interrupt bit and enable the window monitor interrupt. z bit 1 ? overrun: overrun interrupt enable 0: the overrun interrupt is disabled. 1: the overrun interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the overrun interrupt bit and enable the overrun interrupt. z bit 0 ? resrdy: result ready interrupt enable 0: the result ready interrupt is disabled. 1: the result ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the result ready interrupt bit and enable the result ready interrupt. bit76543210 syncrdy winmon overrun resrdy access r r r r r/w r/w r/w r/w reset00000000
504 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.12 interrupt flag status and clear name: intflag offset: 0x18 reset: 0x00 property: ? z bits 7:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? syncrdy: synchronization ready this flag is cleared by writing a one to the flag. this flag is set on a one-to-zero transition of the synchr onization busy bit in the status register (status.sync- busy), except when caused by an enable or software reset, and will generate an interrupt request if intenclr/set.syncrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the synchronization ready interrupt flag. z bit 2 ? winmon: window monitor this flag is cleared by writing a one to the flag or by reading the result register. this flag is set on the next gclk_adc cycle after a match with the window monitor condition, and an interrupt request will be generated if intenclr/set.winmon is one. writing a zero to this bit has no effect. writing a one to this bit clears the window monitor interrupt flag. z bit 1 ? overrun: overrun this flag is cleared by writing a one to the flag. this flag is set if result is written before the prev ious value has been read by cpu, and an interrupt request will be generated if intenclr/set.overrun is one. writing a zero to this bit has no effect. writing a one to this bit clears the overrun interrupt flag. z bit 0 ? resrdy: result ready this flag is cleared by writing a one to the flag or by reading the result register. this flag is set when the conversion result is available, and an interrupt will be generated if inten- clr/set.resrdy is one. writing a zero to this bit has no effect. writing a one to this bit clears the result ready interrupt flag. bit76543210 syncrdy winmon overrun resrdy access r r r r r/w r/w r/w r/w reset00000000
505 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.13 status name: status offset: 0x19 reset: 0x00 property: ? z bit 7 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit76543210 syncbusy accessrrrrrrrr reset00000000
506 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.14 result name: result offset: 0x1a reset: 0x0000 property: read-synchronized z bits 15:0 ? result[15:0]: result conversion value these bits will hold up to a 16-bit adc result, depending on the configuration. in single-ended without averaging mode, the adc conversion will produce a 12-bit result, which can be left- or right-shifted, depending on the setting of ctrlb.leftadj. if the result is left-adjusted (ctrlb.leftadj), the high byte of the result will be in bit position [15:8], while the remaining 4 bits of the result will be placed in bit locations [7:4]. this can be used only if an 8-bit result is required; i.e., one can read only the high byte of the entire 16-bit register. if the result is not left-adjusted (c trlb.leftadj) and no oversampling is used, the result will be available in bit locations [11:0], and the result is then 12 bits long. if oversampling is used, the result will be located in bit locations [15:0], depending on the settings of the average control register ( avgctrl ). bit151413121110 9 8 result[15:8] accessrrrrrrrr reset00000000 bit76543210 result[7:0] accessrrrrrrrr reset00000000
507 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.15 window monitor lower threshold name: winlt offset: 0x1c reset: 0x0000 property: write-synchronized, write-protected z bits 15:0 ? winlt[15:0]: window lower threshold if the window monitor is enabled, these bits define the lower threshold value. bit151413121110 9 8 winlt[15:8] acces s r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 winlt[7:0] acces s r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
508 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.16 window monitor upper threshold name: winut offset: 0x20 reset: 0x0000 property: write-synchronized, write-protected z bits 15:0 ? winut[15:0]: window upper threshold if the window monitor is enabled, these bits define the upper threshold value. bit151413121110 9 8 winut[15:8] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000 bit76543210 winut[7:0] accessr/wr/wr/wr/wr/wr/wr/wr/w reset00000000
509 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.17 gain correction name: gaincorr offset: 0x24 reset: 0x0000 property: write-protected z bits 15:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 11:0 ? gaincorr[11:0]: gain correction value if the ctrlb.corren bit is one, these bits define how the adc conversion result is compensated for gain error before being written to the result register. the gain correc tion is a fractional value, a 1-bit integer plus an 11-bit fraction, and therefore ? <= gaincorr < 2. gaincorr values range from 0.10000000000 to 1.11111111111. bit151413121110 9 8 gaincorr[11:8] accessrrrrr/wr/wr/wr/w reset00000000 bit76543210 gaincorr[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
510 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.18 offset correction name: offsetcorr offset: 0x26 reset: 0x0000 property: write-protected z bits 15:12 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 11:0 ? offsetcorr[11:0]: offset correction value if the ctrlb.corren bit is one, these bits define how t he adc conversion result is compensated for offset error before being written to the result register. this offsetcorr value is in two?s complement format. bit151413121110 9 8 offsetcorr[11:8] access r r r r r/w r/w r/w r/w reset00000000 bit76543210 offsetcorr[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
511 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.19 calibration name: calib offset: 0x28 reset: 0x0000 property: write-protected z bits 15:11 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 10:8 ? bias_cal[2:0]: bias calibration value this value from production test must be loaded from the nv m software calibration area into the calib register by software to achieve the specified accuracy. the value must be copied only, and must not be changed. z bits 7:0 ? linearity_cal[7:0] : linearity calibration value this value from production test must be loaded from the nv m software calibration area into the calib register by software to achieve the specified accuracy. the value must be copied only, and must not be changed. bit151413121110 9 8 bias_cal[2:0] accessrrrrrr/wr/wr/w reset00000000 bit76543210 linearity_cal[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
512 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 28.8.20 debug control name: dbgctrl offset: 0x2a reset: 0x00 property: write-protected z bits 7:1 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 0 ? dbgrun: debug run 0: the adc is halted during debug mode. 1: the adc continues normal operation during debug mode. this bit can be changed only while the adc is disabled. this bit should be written only while a conversion is not ongoing. bit76543210 dbgrun accessrrrrrrrr/w reset00000000
513 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29. ac ? analog comparators 29.1 overview the analog comparator (ac) supports two individual compar ators. each comparator (comp) compares the voltage levels on two inputs, and provides a digital output based on this comparison. each comparator may be configured to generate interrupt requests and/or peripheral events upon several different combinations of input change. hysteresis and propagation delay are two important properties of the comparators; dynamic behavior. both parameters may be adjusted to achieve the optimal operation for each application. the input selection includes four shared analog port pins and several internal signals. each comparator output state can also be output on a pin for use by external devices. the comparators are always grouped in pairs on each port. the ac module may implement one pair. these are called comparator 0 (comp0) and comparator 1 (comp1). they hav e identical behaviors, but separate control registers. the pair can be set in window mode to compare a signal to a voltage range instead of a single voltage level. 29.2 features z two individual comparators z selectable propagation delay versus current consumption z selectable hysteresis z on/off z analog comparator outputs available on pins z asynchronous or synchronous z flexible input selection z four pins selectable for positive or negative inputs z ground (for zero crossing) z bandgap reference voltage z 64-level programmable v ddana scaler per comparator z dac z interrupt generation on: z rising or falling edge z toggle z end of comparison z window function interrupt generation on: z signal above window z signal inside window z signal below window z signal outside window z event generation on: z comparator output z window function inside/outside window z optional digital filter on comparator output z low-power option z single-shot support
514 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.3 block diagram figure 29-1. analog comparator block diagram 29.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 29.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 29.5.1 i/o lines using the ac?s i/o lines requires the i/o pins to be configured. refer to the port chapter for details. refer to ?port? on page 280 for details. interrupt mode enable enable hysteresis hysteresis dac vddana scaler bandgap + - + - cmp0 cmp1 interrupts events gclk_ac ain3 ain2 ain1 ain0 comp0 comp1 compctrln winctrl interrupt sensitivity control & window function signal name type description ain[3..0] analog input comparator inputs cmp[1..0] digital output comparator outputs
515 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.5.2 power management the ac will continue to operate in any sleep mode where the selected source clock is running. the ac?s interrupts can be used to wake up the device from sleep modes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 29.5.3 clocks the ac bus clock (clk_ac_apb) can be enabled and disabl ed in the power manager, and the default state of the clk_ac_apb can be found in the peripheral clock masking section of ?pm ? power manager? on page 101 . two generic clocks (gclk_ac_dig and gclk_ac_ana) are us ed by the ac. the digital clock (gclk_ac_dig) is required to provide the sampling rate for the comparators, while the analog clock (gclk_ac_ana) is required for low- voltage operation (v ddana < 2.5v) to ensure that the resistance of the analog input multiplexors remains low. these clocks must be configured and enabled in the generic clock controller before using the peripheral. refer to ?gclk ? generic clock controller? on page 79 for details. these generic clocks are asynchronous to the clk_ac_apb clock. due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 523 for further details. 29.5.4 interrupts the interrupt request line is connected to the interrupt controller. using the ac interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 29.5.5 events the events are connected to the event system. using the events requires the event system to be configured first. refer to ?evsys ? event system? on page 306 for details. 29.5.6 debug operation when the cpu is halted in debug mode, the peripheral continue s normal operation. if the peripheral is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 29.5.7 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following registers: z control b register ( ctrlb ) z interrupt flag register ( intflag ) write-protection is denoted by the write-protected property in the register description. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 29.5.8 analog connections each comparator has up to four i/o pins that can be used as analog inputs. each pair of comparators shares the same four pins. these pins must be configured for analog operation before using them as comparator inputs. any internal reference source, such as a bandgap reference voltage or the dac, must be configured and enabled prior to its use as a comparator input. 29.5.9 other dependencies not applicable.
516 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.6 functional description 29.6.1 principle of operation each comparator has one positive input and one negative input. each positive input may be chosen from a selection of analog input pins. each negative input may be chosen from a select ion of analog input pins or internal inputs, such as a bandgap reference voltage. the digital output from the comparator is one when the difference between the positive and the negative input voltage is positive, and zero otherwise. the individual comparators can be used independently (nor mal mode) or grouped in pairs to generate a window comparison (window mode). 29.6.2 basic operation 29.6.2.1 initialization before enabling the ac, the input and output events must be configured in the event control register ( evctrl ). these settings cannot be changed while the ac is enabled. each individual comparator must also be configured by its respective comparator control register ( comparator control n ) before that comparator is enabled. these settings cannot be changed while the comparator is enabled. z select the desired measurement m ode with compctrlx.single. see ?starting a comparison? on page 516 for more details z select the desired hysteresis with compctrlx.hyst. see ?input hysteresis? on page 520 for more details z select the comparator speed versus power with compctrlx.speed. see ?propagation delay vs. power consumption? on page 520 for more details z select the interrupt source with compctrlx.intsel z select the positive and negative input sources with the compctrlx.muxpos and compctrlx.muxneg bits. see section ?selecting comparator inputs? on page 518 for more details z select the filtering option with compctrlx.flen 29.6.2.2 enabling, disabling and resetting the ac is enabled by writing a one to the enable bit in the control a register (ctrla.enable). the individual comparators must be also enabled by writing a one to the enable bit in the comparator x control registers (compctrlx.enable). the ac is disabled by writing a zero to ctrla.enable. this will also disable the individual comparators, but will not clear their compctrlx.enable bits. the ac is reset by writing a one to the software reset bit in the control a register (ctrla.swrst). all registers in the ac, except debug, will be reset to their initial state, and the ac will be disabled. refer to the ctrla register for details. 29.6.2.3 starting a comparison each comparator channel can be in one of two different measurement modes, determined by the single bit in the comparator x control register (compctrlx.single): z continuous measurement z single-shot after being enabled, a start-up delay is required before the resu lt of the comparison is ready. this start-up time is measured automatically to account for environmental changes, such as temperature or voltage supply level, and is specified in ?electrical characteristics? on page 563 . during the start-up time, the comp output is not available. if the supply voltage is below 2.5v, the start-up time is also dependent on the voltage doubler. if the supply voltage is guaranteed to be above 2.5v, the voltage doubler can be disabled by writing the low-power mux bit in the control a register (ctrla.lpmux) to one. the comparator can be configured to generate interrupts when the output toggles, when the output changes from zero to one (rising edge), when the output changes from one to zero (falling edge) or at the end of the comparison. an end-of- comparison interrupt can be used with the single-shot mode to chain further events in the system, regardless of the state
517 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 of the comparator outputs. the interrupt mode is set by t he interrupt selection bit group in the comparator control register (compctrlx.intsel). events are generated using the comparator output state, regardless of whether the interrupt is enabled or not. continuous measurement continuous measurement is selected by writing compctrlx.si ngle to zero. in continuous mode, the comparator is continuously enabled and performing comparisons. this ensures that the result of the latest comparison is always available in the current state bit in the status a regist er (statusa.statex). after t he start-up time has passed, a comparison is done and statusa is updated. the com parator x ready bit in the status b register (statusb.readyx) is set, and the appr opriate peripheral events and interrupts are also generated. new comparisons are performed continuously until the compctrlx.enable bit is written to zero. the start-up time applies only to the first comparison. in continuous operation, edge detection of the comparator output for interrupts is done by comparing the current and previous sample. the sampling rate is the gclk_ac_dig frequency. an example of continuous measurement is shown in figure 29-2 . figure 29-2. continuous measurement example for low-power operation, comparisons can be performed duri ng sleep modes without a clock. the comparator is enabled continuously, and changes in the state of the comparator are detected asynchronously. when a toggle occurs, the power manager will start gclk_ac_dig to register the appropriate peripheral events and interrupts. the gclk_ac_dig clock is then disabled again automatically, unless configured to wake up the system from sleep. single-shot single-shot operation is selected by writing compctrlx.sing le to one. during single-shot operation, the comparator is normally idle. the user starts a single comparison by writi ng a one to the respective start comparison bit in the write- only control b register (ctrlb.startx) . the comparator is enabled, and after the start-up time has passed, a single comparison is done and statusa is updated. appropriate per ipheral events and interrupts are also generated. no new comparisons will be performed. writing a one to ctrlb.startx also clears the comparator x ready bit in the status b register (statusb.readyx). statusb.readyx is set automatically by hardware when the single comparison has completed. to remove the need for polling, an additional means of starting the comparison is also available. a read of the status c register (statusc) will start a comparison on all comparators currently configur ed for single-shot operation. the read will stall the bus until all enabled comparators are ready. if a com parator is already busy with a comparison, the read will stall until the current comparison is compete, and a new comparison will not be started. a single-shot measurement can also be triggered by the event system. writing a one to the comparator x event input bit in the event control register (evctrl.compeix) enables triggering on incoming peripheral events. each comparator can be triggered independently by separate events. event-trigger ed operation is similar to user-triggered operation; the difference is that a peripheral event from another hardwar e module causes the hardware to automatically start the comparison and clear statusb.readyx. to detect an edge of the comparator output in single-shot operation for the purpose of interrupts, the result of the current measurement is compared with the result of the previous measurement (one sampling peri od earlier). an example of single-shot operation is shown in figure 29-3 . gclk_ac statusb.readyx sampled comparator output compctrlx.enable t startup write ?1? 2-3 cycles
518 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 29-3. single-shot example for low-power operation, event-triggered measurements can be performed during sleep modes. when the event occurs, the power manager will start gclk_ac_dig. the comparator is enabled, and after the startup time has passed, a comparison is done and appropriate peripheral events and interrupts are also generated. the comparator and gclk_ac_dig are then disabled again automatically, unl ess configured to wake up the system from sleep. 29.6.3 selecting co mparator inputs each comparator has one positive and one negative input. the posit ive input is fed from an external input pin (ainx). the negative input can be fed either from an external input pin (a inx) or from one of the several internal reference voltage sources common to all comparators. the us er selects the input source as follows: z the positive input is selected by the positive input mux select bit group in the comparator control register (compctrlx.muxpos) z the negative input is selected by the negative input mux select bit group in the comparator control register (compctrlx.muxneg) in the case of using an external i/o pin, the selected pin must be configured for analog usage in the port controller by disabling the digital input and output. the switching of the anal og input multiplexors is controlled to minimize crosstalk between the channels. the input selection must be changed only while the individual comparator is disabled. 29.6.4 window operation each comparator pair can be configured to work together in window mode. in this mode, a voltage range is defined, and the comparators give information about whether an input si gnal is within this range or not. window mode is enabled by the window enable x bit in the window control register (w inctrl.wenx). both comparators in a pair must have the same measurement mode setting in their respective comparator control registers (compctrlx.single). to physically configure the pair of comparators for window mode, the same i/o pin should be chosen for each comparator?s positive input to create the shared input signal. the negative inputs define the range for the window. in figure 29-4 , comp0 defines the upper limit and comp1 defines the lower limit of the window, as shown but the window will also work in the opposite configuration with comp0 lower and comp1 higher. the current state of the window function is available in the window x state bit group of the status register (status.wstatex). window mode can be configured to generate interrupts when the input voltage changes to below the window, when the input voltage changes to above the window, when the input voltage changes into the window or when the input voltage changes outside the window. the interrupt selections are set by the window interrupt selection bit group in the window control register (winctrl.wintselx[ 1:0]). events are generated using the inside/outside state of the window, regardless of whether the interrupt is enabled or not. note t hat the individual comparator outputs, interrupts and events continue to function normally during window mode. when the comparators are configured for window mode and single-shot mode, measurements are performed simultaneously on both comparators. writing a one to either start comparison bit in the control b register (ctrlb.startx) starts a measur ement. likewise either peripheral event can start a measurement. gclk_ac statusb.readyx sampled comparator output ctrlb.startx t startup write ?1? t startup write ?1? 2-3 cycles 2-3 cycles
519 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 29-4. comparators in window mode 29.6.5 voltage doubler the ac contains a voltage doubler that can reduce the resistance of the analog multiplexors when the supply voltage is below 2.5v. the voltage doubler is normally switched on/off automatically based on the supply level. when enabling the comparators, additional start-up time is required for the vo ltage doubler to settle. if the supply voltage is guaranteed to be above 2.5v, the voltage doubler can be disabled by writi ng the low-power mux bit in the control a register (ctrla.lpmux) to one. disabling the voltage doubl er saves power and reduces the start-up time. 29.6.6 v ddana scaler the v ddana scaler generates a reference voltage that is a fraction of the device?s supply voltage, with 64 levels. one independent voltage channel is dedicated for each comparator. the scaler is enabled when a comparator?s negative input mux bit group in its comparator control register (compctrlx.muxneg) is set to five and the comparator is enabled. the voltage of each channel is selected by the value bit group in the scaler x registers (scalerx.value[5:0]). + - + - state0 state1 wstate[1:0] interrupts events input signal upper limit of window comp0 comp1 interrupt sensitivity control & window function lower limit of window
520 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 29-5. vddana scaler 29.6.7 input hysteresis application software can selectively enable/disable hysteresis for the comparison. applying hysteresis will help prevent constant toggling of the output, which can be caused by noise when the input signals are close to each other. hysteresis is enabled for each comparator individually by the hyster esis mode bit in the comparator x control register (compctrlx.hyst). hysteresis is available only in continuous mode (compctrlx.single=0). 29.6.8 propagation delay vs. power consumption it is possible to trade off comparison speed for power efficiency to get the shortest possible propagation delay or the lowest power consumption. the speed setting is configured for each comparator individually by the speed bit group in the comparator x control register (com pctrlx.speed). the speed bits select the amount of bias current provided to the comparator, and as such will also affect the start-up time. 29.6.9 filtering the output of the comparators can be digitally filtered to re duce noise using a simple digital filter. the filtering is determined by the filter length bits in the comparator control x register (compctrlx.flen), and is independent for each comparator. filtering is selectable from none, 3-bit majority (n=3) or 5-bit majority (n=5) functions. any change in the comparator output is considered valid only if n/2+1 out of the last n samples agree. the filter sampling rate is the clk_ac frequency scaled by the prescaler setting in the control a register (ctrla.prescaler). note that filtering creates an additional delay of n-1 sa mpling cycles from when a comparison is started until the comparator output is validated. for continuous mode, the first valid output will occur when the required number of filter samples is taken. subsequent outputs will be generated every cycle based on the current sample plus the previous n-1 samples, as shown in figure 29-6 . for single-shot mode, the comparison completes after the nth filter sample, as shown in figure 29-7 . compctrlx.muxneg == 5 scalerx. value to compx 6
521 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 29-6. continuous mode filtering figure 29-7. single-shot filtering during sleep modes, filtering is supported only for single-s hot measurements. filtering must be disabled if continuous measurements will be done during sleep modes, or the resulting interrupt/event may be generated incorrectly. 29.6.10 comparator output the output of each comparator can be routed to an i/o pin by setting the output bit group in the comparator control x register (compctrlx.out). this allows the comparator to be used by external circuitry. either the raw, non- synchronized output of the comparator or the clk_ac-synchr onized version, including filtering, can be used as the i/o signal source. the output appears on the corresponding cmp[x] pin. 29.6.11 offset compensation the swap bit in the comparator control registers (compctr lx.swap) controls switching of the input signals to a comparator's positive and negative terminals. when the compar ator terminals are swapped, the output signal from the comparator is also inverted, as shown in figure 29-8 . this allows the user to measure or compensate for the comparator input offset voltage. as part of the input selection, compctrlx.swap can be changed only while the comparator is disabled. figure 29-8. input swapping for offset compensation sampling clock sampled comparator output 3-bit majority filter output 5-bit majority filter output sampling clock 3- bit sampled comparator output 3-bit majority filter output start 5- bit sampled comparator output 5-bit majority filter output t sut m u xp os m u xne g + - compx s wap enable hy s tere s i s s wa p c mpx compctrlx
522 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.7 additional features 29.7.1 interrupts the peripheral has the following interrupt sources: z comparator: comp0, comp1( intenclr, intset, intflag) z window: win0(intenclr, intset, intflag) comparator interrupts are generated based on the conditions selected by the interrupt selection bit group in the comparator control registers (com pctrlx.intsel). window interrupt s are generated based on the conditions selected by the window interrupt selection bit group in the window control register (winctrl.wintsel[1:0]). each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the peripheral is reset. an interrupt flag is cleared by writing a one to the corresponding bit in the intflag register. each peripheral can have one interrupt request line per interr upt source or one common interrupt request line for all the interrupt sources. if the peripheral has one common interrupt r equest line for all the interrupt sources, the user must read the intflag register to determine which interrupt condition is present. for details on clearing interrupt flags, refer to the intflag register description. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 29.7.2 events the peripheral can generate the following output events: z comparator: compeo0, compeo1(evctrl) z window: wineo0(evctrl) output events must be enabled to be generated. writing a one to an event output bit in the event control register (evctrl.compeox) enables the corresponding output event. wr iting a zero to this bit disables the corresponding output event. the events must be correctly routed in the event system. refer to ?evsys ? event system? on page 306 for details. the peripheral can take the following actions on an input event: z single-shot measurement z single-shot measurement in window mode input events must be enabled for the corresponding action to be taken on any input event. writing a one to an event input bit in the event control register (evctrl.compeix) enables the corresponding action on input event. writing a zero to a bit disables the corresponding action on input event. note that if several events are connected to the peripheral, the enabled action will be taken on any of the incoming events. the events must be correctly routed in the event system. refer to ?evsys ? event system? on page 306 for details. when evctrl.compeix is one, the event will start a com parison on compx after the start-up time delay. in normal mode, each comparator responds to its corresponding i nput event independently. for a pair of comparators in window mode, either comparator event will trigger a comparison on both comparators simultaneously. 29.7.3 sleep mode operation the run in standby bit in the control a register (ctrla.runstdby) controls the behavior of the ac during standby sleep mode. when the bit is zero, the comparator pair is disabled during sleep, but maintains its current configuration. when the bit is one, the comparator pair continues to operat e during sleep. note that when runstdby is zero, the
523 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 analog blocks are powered off for the lowest power consumption. this necessitates a start-up time delay when the system returns from sleep. when runstdby is one, any enabled ac interrupt source c an wake up the cpu. while the cpu is sleeping, single- shot comparisons are only triggerable by events. the ac can also be used during sleep modes where the clock used by the ac is disabled, provided that the ac is still powered (not in shutdown). in this case, the behavior is slightly different and depends on the measurement mode, as listed in table 29-1 . table 29-1. sleep mode operation 29.7.3.1 continuous measurement during sleep when a comparator is enabled in continuous measurement mode and gclk_ac_dig is disabled during sleep, the comparator will remain continuously enabled and will function asynchronously. the current state of the comparator is asynchronously monitored for changes. if an edge matching the interrupt condition is found, gclk_ac_dig is started to register the interrupt condition and generate events. if th e interrupt is enabled in the interrupt enable registers (intenclr/set), the ac can wake up the device; other wise gclk_ac_dig is disabled until the next edge detection. filtering is not possible with this configuration. figure 29-9. continuous mode sleepwalking 29.7.3.2 single-shot measurement during sleep for low-power operation, event-triggered measurements can be performed during sleep modes. when the event occurs, the power manager will start gclk_ac_dig. the comparator is enabled, and after the start-up time has passed, a comparison is done, with filtering if desired, and the appr opriate peripheral events and interrupts are also generated, as shown in figure 29-10 the comparator and gclk_ac_dig are then dis abled again automatically, unless configured to wake the system from sleep. filtering is allowed with this configuration. figure 29-10.single -shot sleepwalking 29.7.4 synchronization due to the asynchronicity between clk_module_apb and gclk_module, some registers must be synchronized when accessed. a register can require: compctrlx.mode runstdby=0 runstdby=1 0 (continuous) compx disabled gclk_ac_dig stopped, compx enabled 1 (single-shot) compx disabled gclk_ac_dig stopped, compx enabled only when triggered by an input event gclk_ac comparator output or event comparator state gclk_ac comparator output or event input event t startup t startup
524 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in control a register (ctrla.swrst) z enable bit in control a register (ctrla.enable) z enable bit in comparator contro l register (compctrln.enable) the following register need synchronization when written: z window control register (winctrl) refer to the synchronization chapter for further details.
525 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.8 register summary offset name bit pos. 0x00 ctrla 7:0 lpmux runstdby enable swrst 0x01 ctrlb 7:0 start1 start0 0x02 evctrl 7:0 wineo0 compeo1 compeo0 0x03 15:8 compei1 compei0 0x04 intenclr 7:0 win0 comp1 comp0 0x05 intenset 7:0 win0 comp1 comp0 0x06 intflag 7:0 win0 comp1 comp0 0x07 reserved 0x08 statusa 7:0 wstate0[1:0] state1 state0 0x09 statusb 7:0 syncbusy ready1 ready0 0x0a statusc 7:0 wstate0[1:0] state1 state0 0x0b reserved 0x0c winctrl 7:0 wintsel0[1:0] wen0 0x0d reserved 0x0e reserved 0x0f reserved 0x10 compctrl0 7:0 intsel[1:0] speed[1:0] single enable 0x11 15:8 swap muxpos[1:0] muxneg[2:0] 0x12 23:16 hyst out[1:0] 0x13 31:24 flen[2:0] 0x14 compctrl1 7:0 intsel[1:0] speed[1:0] single enable 0x15 15:8 swap muxpos[1:0] muxneg[2:0] 0x16 23:16 hyst out[1:0] 0x17 31:24 flen[2:0] 0x18 reserved ... reserved 0x1f reserved 0x20 scaler0 7:0 value[5:0] 0x21 scaler1 7:0 value[5:0]
526 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 515 for details. some registers require synchronization when read and/or wr itten. synchronization is denoted by the write-synchronized or the read-synchronized property in each individual register description. refer to ?synchronization? on page 523 for details. some registers are enable-protected, meaning they can be wr itten only when the ac is disabled. enable-protection is denoted by the enable-protected property in each individual register description. 29.9.1 control a name: ctrla offset: 0x00 reset: 0x00 property: write-protected, write-synchronized z bit 7 ? lpmux: low-power mux 0: the analog input muxes have low resistance, but consume more power at lower voltages (e.g., are driven by the voltage doubler). 1: the analog input muxes have high resistance, but consume less power at lower voltages (e.g., the voltage dou- bler is disabled). this bit are not synchronized z bits 6:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? runstdby: run in standby this bit controls the behavior of the comparators during standby sleep mode. 0: the comparator pair is disabled during sleep. 1: the comparator pair continues to operate during sleep. this bit is not synchronized z bit 1 ? enable: enable 0: the ac is disabled. 1: the ac is enabled. each comparator must also be enabled individually by the enable bit in the comparator control register (compctrln.enable). due to synchronization, there is delay from updating the register until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately after being written. status.syncbusy is set. sta- tus.syncbusy is cleared when t he peripheral is enabled/disabled. bit 76543210 lpmux runstdby enable swrst access r/w r r r r r/w r/w r/w reset00000000
527 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets all registers in the ac to their initial state, and the ac will be disabled. writing a one to ctrl.swrst will always take precedence, meaning that all other writes in the same write-oper- ation will be discarded. due to synchronization, there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete.
528 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.2 control b name: ctrlb offset: 0x01 reset: 0x00 property: ? z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? startx: comparator x start comparison writing a zero to this field has no effect. writing a one to startx starts a single-shot comparison on compx if both the single-shot and enable bits in the comparator x control register are one (compctrlx.s ingle and compctrlx.enable). if comparator x is not implemented, or if it is not enabled in single-shot mode, writing a one has no effect. this bit always reads as zero. bit 76543210 start1 start0 accessrrrrrrww reset00000000
529 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.3 event control name: evctrl offset: 0x02 reset: 0x0000 property: write-protected, enable-protected z bits 15:10 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 9:8 ? compeix: co mparator x event input note that several actions can be enabled for incoming events. if several events are connected to the peripheral, the enabled action will be taken for any of the incoming events. there is no way to tell which of the incoming events caused the action. these bits indicate whether a comparison will start or not on any incoming event. 0: comparison will not start on any incoming event. 1: comparison will start on any incoming event. z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? wineo0: window 0 event output enable this bit indicates whether the window 0 f unction can generate a peripheral event or not. 0: window 0 event is disabled. 1: window 0 event is enabled. z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? compeox: compar ator x event output enable these bits indicate whether the comparator x output can generate a peripheral event or not. 0: compx event generation is disabled. 1: compx event generation is enabled. bit 151413121110 9 8 compei1 compei0 accessrrrrrrr/wr/w reset00000000 bit 76543210 wineo0 compeo1 compeo0 access r r r r/w r r r/w r/w reset00000000
530 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.4 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x04 reset: 0x00 property: write-protected z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? win0: window 0 interrupt enable reading this bit returns the state of the window 0 interrupt enable. 0: the window 0 interrupt is disabled. 1: the window 0 interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit disables the window 0 interrupt. z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? compx: comparator x interrupt enable reading this bit returns the state of the comparator x interrupt enable. 0: the comparator x interrupt is disabled. 1: the comparator x interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit disables the comparator x interrupt. bit76543210 win0 comp1 comp0 access r r r r/w r r r/w r/w reset00000000
531 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.5 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x05 reset: 0x00 property: write-protected z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? win0: window 0 interrupt enable reading this bit returns the state of the window 0 interrupt enable. 0: the window 0 interrupt is disabled. 1: the window 0 interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit enables the window 0 interrupt. z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? compx: comparator x interrupt enable reading this bit returns the state of the comparator x interrupt enable. 0: the comparator x interrupt is disabled. 1: the comparator x interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the ready interrupt bit and enable the ready interrupt. bit 76543210 win0 comp1 comp0 access r r r r/w r r r/w r/w reset00000000
532 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.6 interrupt flag status and clear name: intflag offset: 0x06 reset: 0x00 property: ? z bits 7:5 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 4 ? win0: window 0 this flag is set according to the window 0 interrupt selection bit group in the winctrl register (winc- trl.wintsel0) and will generate an interrupt if intenclr/set.win0 is also one. writing a zero to this bit has no effect. writing a one to this bit clears the window 0 interrupt flag. z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? compx: comparator x reading this bit returns the status of the comparator x interrupt flag. if comparator x is not implemented, compx always reads as zero. this flag is set according to the interrupt selection bit group in the comparator x control register (compc- trlx.intsel) and will generate an interrupt if intenclr/set.compx is also one. writing a zero to this bit has no effect. writing a one to this bit clears the comparator x interrupt flag. bit 76543210 win0 comp1 comp0 access r r r r/w r r r/w r/w reset00000000
533 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.7 status a name: statusa offset: 0x08 reset: 0x00 property: ? z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:4 ? wstate0[1:0]: window 0 current state these bits show the current state of the signal if the window 0 mode is enabled, according to table 29-2 . if the win- dow 0 function is not implemented, wstate0 always reads as zero. table 29-2. window mode current state z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? statex: comp arator x current state this bit shows the current state of the output signal fr om compx. statex is vali d only when statusb.readyx is one. bit76543210 wstate0[1:0] state1 state0 accessrrrrrrrr reset00000000 value name description 0x0 above signal is above window 0x1 inside signal is inside window 0x2 below signal is below window 0x3 ? reserved
534 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.8 status b name: statusb offset: 0x09 reset: 0x00 property: ? z bit 7 ? syncbusy: synchronization busy this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? readyx: comparator x ready this bit is cleared when the comparator x output is not ready. this bit is set when the comparator x output is ready. bit 76543210 syncbusy ready1 ready0 accessrrrrrrrr reset00000000
535 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.9 status c statusc is a copy of statusa (see statusa register), with the additional feature of automatically starting single- shot comparisons. a read of statusc will start a compar ison on all comparators currently configured for single-shot operation. the read will stall the bus until all enabled compar ators are ready. if a comparator is already busy with a comparison, the read will stall until the current comparis on is compete, and a new comparison will not be started. name: statusc offset: 0x0a reset: 0x00 property: ? z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:4 ? wstate0[1:0]: window 0 current state these bits show the current state of the signal if the window 0 mode is enabled. if the window 0 function is not implemented, wstate0 always reads as zero. table 29-3. window mode current state z bits 3:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 1:0 ? statex: comp arator x current state this bit shows the current state of the output signal from compx. if comparator x is not implemented, statex always reads as zero. statex is only valid when statusb.readyx is one. bit76543210 wstate0[1:0] state1 state0 accessrrrrrrrr reset00000000 value name description 0x0 above signal is above window 0x1 inside signal is inside window 0x2 below signal is below window 0x3 ? reserved
536 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.10 window control name: winctrl offset: 0x0c reset: 0x00 property: write-synchronized, write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 2:1 ? wintsel0: window 0 interrupt selection these bits configure the interrupt mode for the comparator window 0 mode. table 29-4. window 0 interrupt selection z bit 0 ? wen0: window 0 mode enable 0: window mode is disabled for comparators 0 and 1. 1: window mode is enabled for comparators 0 and 1. bit 76543210 wintsel0[1:0] wen0 accessrrrrrr/wr/wr/w reset00000000 value name description 0x0 above interrupt on signal above window 0x1 inside interrupt on signal inside window 0x2 below interrupt on signal below window 0x3 outside interrupt on signal outside window
537 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.11 scaler n name: scalern offset: 0x20+n*0x1 [n=0..1] reset: 0x00 property: write-protected z bits 7:6 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 5:0 ? value[5:0]: scaler value these bits define the scaling factor for channel n of the v ddana voltage scaler. the output voltage, v scale , is: bit 76543210 value[5:0] access r r r/w r/w r/w r/w r/w r/w reset00000000 v scale v ddana value 1 + () ? 64 ----------------------------------------------------------- - =
538 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 29.9.12 comparator control n the configuration of comparator n is protected while comparator n is enabled (compctrln.enable = 1). changes to the other bits in compctrln can only occur when compctrln.enable is zero. name: compctrln offset: 0x10+n*0x4 [n=0..1] reset: 0x00000000 property: write-protected, write-synchronized z bits 31:27 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bits 26:24 ? flen[2:0]: filter length these bits configure the filtering for comparator n. compctrln.flen can only be written while compc- trln.enable is zero. these bits are not synchronized. bit 3130292827262524 flen[2:0] accessrrrrrr/wr/wr/w reset00000000 bit 2322212019181716 hyst out[1:0] access r r r r r/w r r/w r/w reset00000000 bit 151413121110 9 8 swap muxpos[1:0] muxneg[2:0] access r/w r r/w r/w r r/w r/w r/w reset00000000 bit 76543210 intsel[1:0] speed[1:0] single enable access r r/w r/w r r/w r/w r/w r/w reset00000000
539 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 29-5. filter length z bits 23:20 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 19 ? hyst: hysteresis enable this bit indicates the hysteresis mode of comparator n. hysteresis is available only for continuous mode (compc- trln.single=0). compctrln.hyst can be writ ten only while compctrln.enable is zero. 0: hysteresis is disabled. 1: hysteresis is enabled. these bits are not synchronized. z bit 18 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 17:16 ? out[1:0]: output these bits configure the output selection for comparat or n. compctrln.out can be written only while compc- trln.enable is zero. these bits are not synchronized. table 29-6. output selection z bit 15 ? swap: swap inputs and invert this bit swaps the positive and negative inputs to compn and inverts the output. this function can be used for off- set cancellation. compctrln.swap can be wri tten only while compctrln.enable is zero. 0: the output of muxpos connects to the positive input, and the output of muxneg connects to the negative input. 1: the output of muxneg connects to the positive input, and the output of muxpos connects to the negative input. these bits are not synchronized. value name description 0x0 off no filtering 0x1 maj3 3-bit majority function (2 of 3) 0x2 maj5 5-bit majority function (3 of 5) 0x3-0x7 n/a reserved value name description 0x0 off the output of compn is not routed to the compn i/o port 0x1 async the asynchronous output of compn is routed to the compn i/o port 0x2 sync the synchronous output (inc luding filtering) of compn is routed to the compn i/o port 0x3 n/a reserved
540 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 z bit 14 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 13:12 ? muxpos[1:0]: positive input mux selection these bits select which input will be connected to the positive input of comparator n. compctrln.muxpos can be written only while compctrln.enable is zero. these bits are not synchronized. table 29-7. positive input mux selection z bit 11 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 10:8 ? muxneg[2:0]: negative input mux selection these bits select which input will be connected to the negative input of comparator n. compctrln.muxneg can only be written while compctrln.enable is zero. these bits are not synchronized. table 29-8. negative input mux selection z bit 7 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 6:5 ? intsel[1:0]: interrupt selection these bits select the condition for comparator n to generate an interrupt or event. compctrln.intsel can be written only while compctrln.enable is zero. these bits are not synchronized. value name description 0x0 pin0 i/o pin 0 0x1 pin1 i/o pin 1 0x2 pin2 i/o pin 2 0x3 pin3 i/o pin 3 value name description 0x0 pin0 i/o pin 0 0x1 pin1 i/o pin 1 0x2 pin2 i/o pin 2 0x3 pin3 i/o pin 3 0x4 gnd ground 0x5 vscale v ddana scaler 0x6 bandgap internal bandgap voltage 0x7 dac dac output
541 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 29-9. interrupt selection z bit 4 ? reserved this bit is unused and reserved for future use. for compatibility with future devices, always write this bit to zero when this register is written. this bit will always return zero when read. z bits 3:2 ? speed[1:0]: speed selection this bit indicates the speed/propagation delay mode of comparator n. compctrln.speed can be written only while compctrln.enable is zero. these bits are not synchronized. table 29-10. speed selection z bit 1 ? single: single-shot mode this bit determines the operation of comparator n. compctrln.single can be written only while compc- trln.enable is zero. 0: comparator n operates in continuous measurement mode. 1: comparator n operates in single-shot mode. these bits are not synchronized. z bit 0 ? enable: enable writing a zero to this bit disables comparator n. writing a one to this bit enables comparator n. after writing to this bit, the value read back will not change until the action initiated by the writing is complete. due to synchronization, there is a latency of at least two gclk_ac_dig clock cycles from updating the register until the comparator is enabled/disabled. the bit will continue to read the previous state while the change is in progress. writing a one to compctrln.enable will prevent further changes to the other bits in compctrln. these bits remain protected until compctrln.enable is written to zero and the write is synchronized. value name description 0x0 toggle interrupt on comparator output toggle 0x1 rising interrupt on comparator output rising 0x2 falling interrupt on comparator output falling 0x3 eoc interrupt on end of comparison (single-shot mode only) value name description 0x0 low low speed 0x1 high high speed 0x2-0x3 reserved
542 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30. dac ? digital-to-analog converter 30.1 overview the digital-to-analog converter (dac) converts a digita l value to a voltage. the dac has one channel with 10-bit resolution, and it is capable of converting up to 350,000 samples per second (350ksps). 30.2 features z dac with 10-bit resolution z up to 350ksps conversion rate z multiple trigger sources z high-drive capabilities z output can be used as input to the analog comparator (ac) 30.3 block diagram figure 30-1. dac block diagram 30.4 signal description refer to ?i/o multiplexing and considerations? on page 11 for the pin mapping of this peripheral. one signal can be mapped on several pins. evctrl databuf data ctrla ctrlb status event control dac10 output driver av cc int1v vrefa v out adc ac empty start signal name type description vout analog output dac output vrefa analog input external reference
543 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.5 product dependencies in order to use this peripheral, other parts of the system must be configured correctly, as described below. 30.5.1 i/o lines using the dac?s i/o lines requires the i/o pins to be configured using the port configuration (port). refer to ?port? on page 280 for details. 30.5.2 power management the dac will continue to operate in any sleep mode where the selected source clock is running. the dac interrupts can be used to wake up the device from sleep modes. the events can trigger other operations in the system without exiting sleep modes. refer to ?pm ? power manager? on page 101 for details on the different sleep modes. 30.5.3 clocks the dac bus clock (clk_dac_apb) can be enabled and dis abled in the power manager, and the default state of clk_dac_apb can be found in the peripheral clock masking section in ?pm ? power manager? on page 101 . a generic clock (gclk_dac) is required to clock the dac. this clock must be configured and enabled in the generic clock controller before using the dac. refer to ?gclk ? generic clock controller? on page 79 for details. this generic clock is asynchronous to the bus clock (clk_dac). due to this asynchronicity, writes to certain registers will require synchronization between the clock domains. refer to ?synchronization? on page 546 for further details. 30.5.4 dma not applicable. 30.5.5 interrupts the interrupt request line is connected to the interrupt c ontroller. using the dac interrupts requires the interrupt controller to be configured first. refer to ?nested vector interrupt controller? on page 25 for details. 30.5.6 events the events are connected to the event system. refer to ?evsys ? event system? on page 306 for details on how to configure the event system. 30.5.7 debug operation when the cpu is halted in debug mode the dac continues normal operation. if the dac is configured in a way that requires it to be periodically serviced by the cpu through inte rrupts or similar, improper operation or data loss may result during debugging. 30.5.8 register access protection all registers with write-access are optionally write-protected by the peripheral access controller (pac), except the following register: z interrupt flag status and clear register ( intflag ) write-protection is denoted by the write-protection property in the register description. when the cpu is halted in debug mode, all writ e-protection is automatically disabled. write-protection does not apply for accesses through an external debugger. refer to ?pac ? peripheral access controller? on page 28 for details. 30.5.9 analog connections not applicable.
544 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.6 functional description 30.6.1 principle of operation the digital-to-analog converter (dac) converts the digital value written to the data register ( data ) into an analog voltage on the dac output. by default, a conversion is star ted when new data is written to data, and the corresponding voltage is available on the dac output after the conversion time. it is also possible to enable events from the event system to trigger the conversion. 30.6.2 basic operation 30.6.2.1 initialization before enabling the dac, it must be configured by selecting the voltage reference using the reference selection bits in the control b register (ctrlb.refsel). 30.6.2.2 enabling, disabling and resetting the dac is enabled by writing a one to the enable bit in t he control a register (ctrla.e nable). the dac is disabled by writing a zero to ctrla.enable. the dac is reset by writing a one to the software reset bit in the control a register (ctrla.s wrst). all registers in the dac will be reset to their initial state, and the dac will be disabled. refer to the ctrla register for details. 30.6.2.3 enabling the output buffer to enable the dac output on the v out pin, the output driver must be enabled by writing a one to the external output enable bit in the control b register (ctrlb.eoen). the dac output buffer provides a high-drive-strength output , and is capable of driving both resistive and capacitive loads. to minimize power consumption, the output buffer should be enabled only when external output is needed. 30.6.3 additional features 30.6.3.1 conversion range the conversion range is between gnd and the selected dac voltage reference. the default voltage reference is the internal 1v (int1v) reference voltage. the other volt age reference options are the 3.3v analog supply voltage (av cc = vddana) and the external voltage referenc e (vrefp). the voltage reference is selected by writing to the reference selection bits in the control b register (ctrlb.refsel) . the output voltage from the dac can be calculated using the following formula: 30.6.3.2 dac as an internal reference the dac output can be internally enabled as input to the analog comparator. this is enabled by writing a one to the internal output enable bit in the control b register (ctrlb .ioen). it is possible to have the internal and external output enabled simultaneously. the dac output can also be enabled as input to the analog-to-digital converter. in this case, the output buffer must be enabled. 30.6.3.3 data buffer the data buffer register ( databuf ) and the data register ( data ) are linked together to form a two-stage fifo. the dac uses the start conversion event to load data from databuf into data and start a new conversion. the start conversion event is enabled by writing a one to the star t event input bit in the event control register (evctrl.startei). if a start conversion event occurs when databuf is empty, an u nderrun interrupt request is generated if the underrun interrupt is enabled. v dac data 0 x 3 ff ---------------- - vref ? =
545 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the dac can generate a data buffer empty event when databuf becomes empty and new data can be loaded to the buffer. the data buffer empty event is enabled by writing a one to the empty event output bit in the event control register (evctrl.em ptyeo). a data buffer empty interrupt request is generated if the data buffer empty interrupt is enabled. 30.6.3.4 voltage pump when the dac is used at operating voltages lower than 2.5v, the voltage pump must be enabled. this enabling is done automatically, depending on operating voltage. the voltage pump can be disabled by writing a one to the voltage pump disable bit in the control b register (ctrlb.vpd). this can be used to reduce power consumption when the operating voltage is above 2.5v. the voltage pump uses the asynchronous gclk_dac clock, and requires that the clock frequency be at least four times higher than the sampling period. 30.6.3.5 sampling period as there is no automatic indication that a conversion is done, the sampling period must be greater than or equal to the specified conversion time. 30.6.4 dma operation not applicable. 30.6.5 interrupts the dac has the following interrupt sources: z data buffer empty z underrun z synchronization ready each interrupt source has an interrupt flag associated with i t. the interrupt flag in the interrupt flag status and clear register (intflag) is set when the interrupt condition occu rs. each interrupt can be individually enabled by writing a one to the corresponding bit in the interrupt enable set regi ster (intenset), and disabled by writing a one to the corresponding bit in the interrupt enable clear register (int enclr). an interrupt request is generated when the interrupt flag is set and the corresponding interrupt is enabled. the interrupt request remains active until the interrupt flag is cleared, the interrupt is disabled or the dac is reset. see the register description for details on how to clear interrupt flags. the dac has one common interrupt request line for all the interrupt sources. the user must read the intflag register to determine which interrupt condition is present. note that interrupts must be globally enabled for interrupt requests to be generated. refer to ?nested vector interrupt controller? on page 25 for details. 30.6.6 events the dac can generate the following output events: z data buffer empty (empty) writing a one to an event output bit in the event control register (evctrl.xxeo) enables the corresponding output event. writing a zero to this bit disables the corresponding output event. refer to ?evsys ? event system? on page 306 for details on configuring the event system. the dac can take the following actions on an input event: z start conversion (start) writing a one to an event input bit in the event control register (evctrl.xxei) enables the corresponding action on an input event. writing a zero to this bit disables the corresponding action on input event. note that if several events are
546 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 connected to the dac, the enabled action will be taken on any of the incoming events. refer to ?evsys ? event system? on page 306 for details on configuring the event system. 30.6.7 sleep mode operation the generic clock for the dac is running in idle sleep mode. if the run in standby bit in the control a register (ctrla.runstdby) is one, the dac output buffer will keep its value in standby sleep mode. if ctrla.runstdby is zero, the dac output buffer will be disabled in standby sleep mode. 30.6.8 synchronization due to the asynchronicity between clk_dac_apb and gclk_dac, some registers must be synchronized when accessed. a register can require: z synchronization when written z synchronization when read z synchronization when written and read z no synchronization when executing an operation that requires synchronization, the synchronization busy bit in the status register (status.syncbusy) will be set immediately, and cleared when synchronization is complete. the synchronization ready interrupt can be used to signal when synchronization is complete. if an operation that requires synchronization is executed wh ile status.syncbusy is one, the bus will be stalled. all operations will complete successfully, but the cpu will be stalled and interrupts will be pending as long as the bus is stalled. the following bits need synchronization when written: z software reset bit in the control a register (ctrla.swrst) z enable bit in the control a register (ctrla.enable) z all bits in the data register (data) z all bits in the data buffer register (databuf) synchronization is denoted by the write-synchronized property in the register description. the following bits need synchronization when read: z all bits in the data register (data)
547 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.7 register summary offset name bit pos. 0x00 ctrla 7:0 runstdby enable swrst 0x01 ctrlb 7:0 refsel[1:0] vpd leftadj ioen eoen 0x02 evctrl 7:0 emptyeo startei 0x03 reserved 0x04 intenclr 7:0 syncrdy empty underrun 0x05 intenset 7:0 syncrdy empty underrun 0x06 intflag 7:0 syncrdy empty underrun 0x07 status 7:0 syncbusy 0x08 data 7:0 data[7:0] 0x09 15:8 data[15:8] 0x0a reserved 0x0b reserved 0x0c databuf 7:0 databuf[7:0] 0x0d 15:8 databuf[15:8] 0x0e reserved 0x0f reserved
548 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8 register description registers can be 8, 16 or 32 bits wide. atomic 8-, 16- and 32- bit accesses are supported. in addition, the 8-bit quarters and 16-bit halves of a 32-bit register and the 8-bit hal ves of a 16-bit register can be accessed directly. some registers are optionally write-protected by the perip heral access controller (pac). write-protection is denoted by the write-protected property in each individual register description. refer to ?register access protection? on page 543 for details. some registers require synchronization when read and/or written. synchronization is denoted by the synchronized property in each individual register description. refer to ?synchronization? on page 546 for details.
549 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.1 control a name: ctrla offset: 0x0 reset: 0x00 property: write-protected, write-synchronized z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? runstdby: run in standby 0: the dac output buffer is disabled in standby sleep mode. 1: the dac output buffer can be enabled in standby sleep mode. this bit is not synchronized. z bit 1 ? enable: enable 0: the peripheral is disabled or being disabled. 1: the peripheral is enabled or being enabled. due to synchronization, there is delay from writing ctrla.enable until the peripheral is enabled/disabled. the value written to ctrl.enable will read back immediately and the synchronization busy bit in the status register (status.syncbusy) will be set. status.syncbus y is cleared when the operation is complete. z bit 0 ? swrst: software reset 0: there is no reset operation ongoing. 1: the reset operation is ongoing. writing a zero to this bit has no effect. writing a one to this bit resets the all registers in the dac to their initial state, and the dac will be disabled. writing a one to ctrla.swrst will alwa ys take precedence, meaning that all other writes in the same write oper- ation will be discarded. due to synchronization, there is a delay from writing ctrla.swrst until the reset is complete. ctrla.swrst and status.syncbusy will both be cl eared when the reset is complete. bit76543210 runstdby enable swrst accessrrrrrr/wr/wr/w reset00000000
550 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.2 control b name: ctrlb offset: 0x1 reset: 0x00 property: write-protected z bits 7:6 ? refsel[1:0]: reference selection these bits select the reference voltage for the dac according to table 30-1 . table 30-1. reference selection z bits 5:4 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 3 ? vpd: voltage pump disable this bit controls the behavior of the voltage pump. 0: voltage pump is turned on/off automatically. 1: voltage pump is disabled. z bit 2 ? leftadj: left-adjusted data this bit controls how the 10-bit conversion data is adjusted in the data and data buffer registers. 0: data and databuf regi sters are right-adjusted. 1: data and databuf registers are left-adjusted. z bit 1 ? ioen: internal output enable 0: internal dac output not enabled. 1: internal dac output enabled to be used by the ac. z bit 0 ? eoen: external output enable 0: the dac output is turned off. 1: the high-drive output buffer drives the dac output to the v out pin. bit76543210 refsel[1:0] - vpd leftadj ioen eoen access r/w r/w r r r/w r/w r/w r/w reset00000000 refsel[1:0] reference selection description 0x0 int1v internal 1.0v reference 0x1 avcc av cc 0x2 vrefp external reference 0x3 reserved
551 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.3 event control name: evctrl offset: 0x2 reset: 0x00 property: write-protected z bits 7:2 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 1 ? emptyeo: data bu ffer empty event output this bit indicates whether or not the data buffer empty event is enabled and will be generated when the data buf- fer register is empty. 0: data buffer empty event is disabled and will not be generated. 1: data buffer empty event is enabled and will be generated. z bit 0 ? startei: start conversion event input this bit indicates whether or not the start conversi on event is enabled and data are loaded from the data buffer register to the data register upon event reception. 0: a new conversion will not be triggered on an incoming event. 1: a new conversion will be triggered on an incoming event. bit76543210 emptyeo startei accessrrrrrrr/wr/w reset00000000
552 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.4 interrupt enable clear this register allows the user to disable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable set register (intenset). name: intenclr offset: 0x4 reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization read y interrupt enable bit, which disables the synchroniza- tion ready interrupt. z bit 1 ? empty: data buff er empty interrupt enable 0: the data buffer empty interrupt is disabled. 1: the data buffer empty interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the data buffer empty interrupt enable bit, which disables the data buffer empty interrupt. z bit 0 ? underrun: underrun interrupt enable 0: the underrun interrupt is disabled. 1: the underrun interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will clear the underrun interrupt enable bit, which disables the underrun interrupt. bit76543210 syncrdy empty underrun accessrrrrrr/wr/wr/w reset00000000
553 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.5 interrupt enable set this register allows the user to enable an interrupt without doing a read-modify-write operation. changes in this register will also be reflected in the interrupt enable clear register (intenclr). name: intenset offset: 0x5 reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? syncrdy: synchronization ready interrupt enable 0: the synchronization ready interrupt is disabled. 1: the synchronization ready interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the synchronization ready interrupt enable bit, which enables the synchronization ready interrupt. z bit 1 ? empty: data buff er empty interrupt enable 0: the data buffer empty interrupt is disabled. 1: the data buffer empty interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the data buffer empty interrupt enable bit, which enables the data buffer empty interrupt. z bit 0 ? underrun: underrun interrupt enable 0: the underrun interrupt is disabled. 1: the underrun interrupt is enabled. writing a zero to this bit has no effect. writing a one to this bit will set the underrun interrupt enable bit, which enables the underrun interrupt. bit76543210 syncrdy empty underrun accessrrrrrr/wr/wr/w reset00000000
554 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.6 interrupt flag status and clear name: intflag offset: 0x6 reset: 0x00 property: write-protected z bits 7:3 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. z bit 2 ? syncrdy: synchronization ready this flag is cleared by writing a one to the flag. this flag is set on a 1-to-0 transition of the synchroniza tion busy bit in the status register (status.syncbusy), except when the transition is caused by an enable or a software reset, and will generate an interrupt request if intenclr/set.ready is one. writing a zero to this bit has no effect. writing a one to this bit will clear the synchronization ready interrupt flag. z bit 1 ? empty: data buffer empty this flag is cleared by writing a one to the flag or by writing new data to databuf. this flag is set when data is transferred from databuf to data, and the dac is ready to receive new data in databuf, and will generate an interrupt request if in tenclr/set.empty is one. writing a zero to this bit has no effect. writing a one to this bit will clear the data buffer empty interrupt flag. z bit 0 ? underrun: underrun this flag is cleared by writing a one to the flag. this flag is set when a start conversion event occurs when databuf is empty, and will generate an interrupt request if intenclr/set.underrun is one. writing a zero to this bit has no effect. writing a one to this bit will clear the underrun interrupt flag. bit76543210 syncrdy empty underrun access r r r r r r/w r/w r/w reset00000000
555 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.7 status name: status offset: 0x7 reset: 0x00 property: read-synchronized z bit 7 ? syncbusy: synchronization busy status this bit is cleared when the synchronization of registers between the clock domains is complete. this bit is set when the synchronization of registers between clock domains is started. z bits 6:0 ? reserved these bits are unused and reserved for future use. for compatibility with future devices, always write these bits to zero when this register is written. t hese bits will always return zero when read. bit76543210 syncbusy accessrrrrrrrr reset00000000
556 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.8 data name: data offset: 0x8 reset: 0x0000 property: write-synchronized, read-synchronized, write-protected z bits 15:0 ? data: data value to be converted data register contains the 10-bit value that is convert ed to a voltage by the dac. the adjustment of these 10 bits within the 16-bit register is controlled by ctrlb.leftadj: - data[9:0] when ctrlb.leftadj is zero. - data[15:6] when ctrlb.leftadj is one. bit151413121110 9 8 data[15:8] accessrrrrrrr/wr/w reset00000000 bit76543210 data[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
557 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 30.8.9 data buffer name: databuf offset: 0xc reset: 0x0000 property: write-synchronized, write-protected z bits 15:0 ? databuf: data buffer databuf contains the value to be transferred into data register. bit151413121110 9 8 databuf[15:8] access r r r r r r r/w r/w reset00000000 bit76543210 databuf[7:0] access r/w r/w r/w r/w r/w r/w r/w r/w reset00000000
558 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 31. ptc - peripheral touch controller 31.1 overview the purpose of ptc is to acquire signals to detect touch on capacitive sensors. the external capacitive touch sensor is typically formed on a pcb, and the sensor electrodes are connected to the analog front end of the ptc through the i/o pins in the device. the ptc supports both self- and mutual-capacitance sensors. in mutual-capacitance mode, sensing is done using capacitive touch matrices in various x-y configurations, including indium tin oxide (ito) sensor grids. the ptc requires one pin per x-line and one pin per y-line. in self-capacitance mode, the ptc requires onl y one pin (y-line) for each touch sensor. 31.2 features z low-power, high-sensitivity, environmentally robust capaciti ve touch buttons, sliders, wheels and proximity sensing z down to 8a with 200ms scan rate z supports mutual capacitance and self-capacitance sensing z 6/10/16 buttons in self-capacitance mo de, for 32-/48-/64- pins respectively z 60/120/256 buttons in mutual-capacitance mode, for 32-/48-/64- pins respectively z mix-and-match mutual-and self-capacitance sensors z one pin per electrode ? no external components z load compensating charge sensing z parasitic capacitance compensation and ad justable gain for superior sensitivity z zero drift over the temperature and v dd range z auto calibration and re-calibration of sensors z single-shot and free-running charge measurement z hardware noise filtering and noise signal de-synchronization for high conducted immunity z selectable channel change delay z allows choosing the settling time on a new channel, as required z acquisition-start triggered by command or interrupt event z low cpu utilization through interrupt on acquisition-complete z 5% cpu utilization scanning 10 channels at 50ms scan rate z supported by the atmel ? qtouch ? composer development tool, which comprises qtouch library project builder and qtouch analyzer
559 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 31.3 block diagram figure 31-1. ptc block diagram mutual-capacitance figure 31-2. ptc block diagram self-capacitance 100k 10 irq acquisition module ?gain control ?adc ?filtering r s compensation circuit x line driver input control y 0 y 1 y 15 result x 0 x 1 x 15 x line driver c y15 100k 10 irq acquisition module ?gain control ?adc ?filtering r s compensation circuit input control c y0 y 0 y 1 y 15 result
560 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 31.4 signal description note: 1. the number of x and y lines are device dependent. refer to ?configuration summary? on page 3 for details. refer to ?i/o multiplexing and considerations? on page 11 for details on the pin mapping for this peripheral. one signal can be mapped on several pins. 31.5 product dependencies in order to use this peripheral, configure the other components of the system as described in the following sections. 31.5.1 i/o lines the i/o lines used for analog x-lines and y-lines must be connec ted to external capacitive touch sensor electrodes. external components are not required for normal operation. howe ver, to improve the emc performance, a series resistor of 1 k can be used on x-lines and y-lines. mutual-capacitance sensor arrangement a mutual-capacitance sensor is formed between two i/o lines - an x electrode for transmitting and y electrode for receiving. the mutual capacitance between the x and y elec trode is measured by the pe ripheral touch controller. figure 31-3. mutual capacitance sensor arrangement name type description x[n:0] digital x-line (output) y[m:0] analog y-line (input/output) ptc module mcu x 0 x n y 0 y m x 1 y 1 sensor capacitance c x,y c x0,y0 c x0,y1 c x0,ym c x1,y0 c x1,y1 c x1,ym c xn,y0 c xn,y1 c xn,ym ptc module
561 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 self-capacitance sensor arrangement the self-capacitance sensor is connected to a single pin on the peripheral touch controll er through the y electrode for receiving the signal. the sense electrode capacitance is measured by the peripheral touch controller. figure 31-4. self-capacitance sensor arrangement for more information about designing the touch sensor, refer to buttons, sliders and wheels touch sensor design guide on http://www.atmel.com. 31.5.2 clocks the ptc is clocked by the gclk_ptc clock. the ptc operates from an asynchronous clock source and the operation is independent of the main system clock and its derivative clocks, such as the peripheral bus clock (clk_apb). a number of clock sources can be selected as the source for the asynchronous gclk_ptc. the clock source is selected by configuring the generic clock selection id in the generic clock control register. for more information about selecting the clock sources, refer to ?gclk ? generic clock controller? on page 79 . the selected clock must be enabled in the power manager, before it can be used by the ptc. by default these clocks are disabled. the frequency range of gclk_ptc is 400khz to 4mhz. for more details, refer to ?pm ? power manager? on page 101 . mcu ptc module y 0 y 1 y m c y0 c y1 c ym sensor capacitance c y
562 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 31.6 functional description in order to access the ptc, the user must use the qtouc h composer tool to configure and link the qtouch library firmware with the application code. qtouch library can be used to implement buttons, sliders, wheels and proximity sensor in a variety of combinations on a single interface. for more information about qtouch library, refer to the atmel qtouch library peripheral touch controller user guide. figure 31-5. qtouch library usage custom code application link atmel qtouch library compiler
563 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32. electrical characteristics 32.1 disclaimer all typical values are measured at t = 25c unless otherwis e specified. all minimum and maximum values are valid across operating temperature and voltage unless otherwise specified. 32.2 absolute maximum ratings stresses beyond those listed in table 32-1 may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. exposure to absolute maxi mum rating conditions for extended periods may affect device reliability. table 32-1. absolute maximum ratings note: 1. maximum source current is 46ma and maximum sink current is 65ma per cluster. a cluster is a group of gpios as shown in table 32-2 . also note that each v dd /gnd pair is connected to 2 clusters so current con- sumption through the pair will be a sum of the clusters source/sink currents. symbol parameter min. max. units v dd power supply voltage 0 3.8 v i vdd current into a v dd pin - 92 (1) ma i gnd current out of a gnd pin - 130 (1) ma v pin pin voltage with respect to gnd and v dd gnd-0.3v v dd +0.3v v t storage storage temp -60 150 c
564 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 32-2. gpio clusters 32.3 general operating ratings the device must operate within the ratings listed in table 32-3 in order for all other electr ical characteristics and typical characteristics of the device to be valid. table 32-3. general operating conditions notes: 1. with bod33 disabled. if the bod33 is enabled, check table 32-15 package cluster gpio supplies pins connected to the cluster 64pins 1 pb31 pb30 pa31 pa30 vddin pin56/gnd pin54 2 pa28 pa27 pb23 pb22 vddin pin56/gnd pin54 and vddio pin 48/gnd pin47 3 pa25 pa24 pa23 pa22 pa21 pa20 pb17 pb16 pa19 pa18 pa17 pa16 vddio pin 48/gnd pin47 and vddio pin34/gnd pin33 4 pa15 pa14 pa13 pa12 pb15 pb14 pb13 pb12 pb11 pb10 vddio pin 34/gnd pin33 and vddio pin21/gnd pin22 5 pa11 pa10 pa09 pa08 vddio pin21/gnd pin22 6 pa07 pa06 pa05 pa04 pb09 pb08 pb07 pb06 vddana pin 8/gndana pin7 7 pb05 pb04 pa03 pa02 pa01 pa00 pb03 pb02 pb01 pb00 vddana pin 8/gndana pin7 48pins 1 pa31 pa30 vddin pin44/gnd pin42 2 pa28 pa27 pb23 pb22 vddin pin44/gnd pin42 and vddio pin36/gnd pin35 3 pa25 pa24 pa23 pa22 pa21 pa20 pa19 pa18 pa17 pa16 pa15 pa14 pa13 pa12 pb11 pb10 vddio pin36/gnd pin35 and vddio pin17/gnd pin18 4 pa11 pa10 pa09 pa08 vddio pin17/gnd pin18 5 pa07 pa06 pa05 pa04 pb09 pb08 vddana pin6/gndana pin5 6 pa03 pa02 pa01 pa00 pb03 pb02 vddana pin6/gndana pin5 32pins 1 pa31 pa30 vddin pin30/gnd pin 28 2 pa28 pa27 pa25 pa24 pa23 pa22 pa19 pa18 pa17 pa16 pa15 pa14 pa11 pa10 pa09 pa08 vddin pin30/gnd pin 28 and vddana pin9/gnd pin10 3 pa07 pa06 pa05 pa04 pa03 pa02 pa01 pa00 vddana pin9/gnd pin10 symbol parameter min. typ. max. units v dd power supply voltage 1.62 (1) 3.3 3.63 v v ddana analog supply voltage 1.62 (1) 3.3 3.63 v t a temperature range -40 25 85 c t j junction temperature - - 100 c
565 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.4 supply characteristics the following characteristics are applicabl e to the operating temperature range: t a = -40c to 85c, unless otherwise specified and are valid for a junction temperature up to t j = 100c. refer to ?power supply and start-up considerations? on page 16 . table 32-4. supply characteristics table 32-5. supply rise rates 32.5 maximum clock frequencies symbol conditions voltage min. max. units v ddio v ddin v ddana full voltage range 1.62 3.63 v symbol parameter rise rate units max. v ddio v ddin v ddana dc supply peripheral i/os, internal regulator and analog supply voltage 0.1 v/s table 32-6. maximum clock frequencies symbol parameter description max. units f cpu cpu clock frequency i 48 mhz f ahb ahb clock frequency i f apba apba clock frequency i f apbb apbb clock frequency i f apbc apbc clock frequency i f gclk0 gclk0 clock frequency dfll48m reference f gclk1 gclk1 clock frequency wdt i f gclk2 gclk2 clock frequency rtc i f gclk3 gclk3 clock frequency eic ii f gclk4 gclk4 clock frequency evsys_channel_0 i f gclk5 gclk5 clock frequency i evsys_channel_1 f gclk6 gclk6 clock frequency evsys_channel_2 i f gclk7 gclk7 clock frequency i evsys_channel_3 f gclk8 gclk8 clock frequency evsys_channel_4 i f gclk9 gclk9 clock frequency evsys_channel_5 i
566 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 f gclk10 gclk10 clock frequency evsys_channel_6 i 48 mhz f gclk11 gclk11 clock frequency evsys_channel_7 i f gclk12 gclk12 clock frequency sercomx_slow i f gclk13 gclk13 clock frequency sercom0_core f gclk14 gclk14 clock frequency i sercom1_core f gclk15 gclk15 clock frequency sercom2_core i f gclk16 gclk16 clock frequency sercom3_core i f gclk17 gclk17 clock frequency sercom4_core i f gclk18 gclk18 clock frequency sercom5_core i f gclk19 gclk19 clock frequency tc0,tc1 f gclk20 gclk20 clock frequency tc2,tc3 f gclk21 gclk21 clock frequency tc4,tc5 i f gclk22 gclk22 clock frequency tc6,tc7 i f gclk23 gclk23 clock frequency i adc f gclk24 gclk24 clock frequency ac_dig i f gclk25 gclk25 clock frequency ac_ana i f gclk26 gclk26 clock frequency dac i f gclk27 gclk27 clock frequency ptc i table 32-6. maximum clock frequencies (continued) symbol parameter description max. units
567 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.6 power consumption the values in table 32-7 are measured values of power consumption under the following conditions, except where noted: z operating conditions z v vddin = 3.3v z wake up time from sleep mode is measured from the edge of the wakeup signal to the execution of the first instruction fetched in flash. z oscillators z xosc (crystal oscillator) stopped z xosc32k (32khz crystal oscillator ) running with external 32khz crystal z dfll48m using xosc32k as reference and running at 48mhz z clocks z dfll48m used as main clock source z cpu, ahb clocks undivided z apba clock divided by 4 z apbb and apbc bridges off z the following ahb module clocks are running: nvmctrl, apba bridge z all other ahb clocks stopped z the following peripheral clocks running: pm, sysctrl, rtc z all other peripheral clocks stopped z i/os are inactive with internal pull-up z cpu is running on flash with 1 wait states z low power cache enabled z bod33 disabled
568 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 32-7. current consumption mode conditions t a min. typ. max. units active cpu running a while(1) algorithm 25c 2.13 2.33 2.52 ma 85c 2.24 2.44 2.63 cpu running a while(1) algorithm v ddin =1.8v, cpu is running on flash with 3 wait states 25c 2.13 2.34 2.53 85c 2.26 2.45 2.64 cpu running a while(1) algorithm, cpu is running on flash with 3 wait states with gclkin as reference 25c - 42*freq +118 - a (with freq in mhz) 85c - 42*freq +208 - cpu running a fibonacci algorithm 25c 3.63 4.03 4.37 ma 85c 3.74 4.12 4.44 cpu running a fibonacci algorithm v ddin =1.8v, cpu is running on flash with 3 wait states 25c 3.64 4.03 4.37 85c 3.76 4.13 4.44 cpu running a fibonacci algorithm, cpu is running on flash with 3 wait states with gclkin as reference 25c - 80*freq +118 - a (with freq in mhz) 85c - 80*freq +208 - cpu running a coremark algorithm 25c 5.22 5.72 6.16 ma 85c 5.36 5.89 6.37 cpu running a coremark algorithm v ddin =1.8v, cpu is running on flash with 3 wait states 25c 4.58 4.95 5.27 85c 4.74 5.10 5.42 cpu running a coremark algorithm, cpu is running on flash with 3 wait states with gclkin as reference 25c - 94*freq +118 - a (with freq in mhz) 85c - 96*freq +210 - idle0 i 25c 1.24 1.35 1.45 ma 85c 1.31 1.45 1.57 idle1 i 25c 0.87 0.95 1.03 85c 0.91 1.03 1.13 idle2 i 25c 0.72 0.78 0.85 85c 0.76 0.86 0.96 standby xosc32k running rtc running at 1khz 25c - 3.80 11.95 a 85c - 39.91 100 xosc32k and rtc stopped 25c - 2.46 11.13 85c - 38.23 100
569 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 32-8. wake-up time figure 32-1. measurement schematic mode conditions t a min. typ. max. units idle0 osc8m used as main clock source, low power cache disabled 25c 3.3 4.0 4.5 s 85c 3.4 4.0 4.5 idle1 i osc8m used as main clock source, low power cache disabled 25c 10.5 12.1 13.7 85c 12.1 13.6 15.0 idle2 i osc8m used as main clock source, low power cache disabled 25c 11.7 13.0 14.3 85c 13.0 14.5 15.9 standby i osc8m used as main clock source, low power cache disabled 25c 17.5 19.6 21.4 85c 18.0 19.7 21.4 vddin vddana vddio vddcore sam d20 amp 0
570 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.7 i/o pin ch aracteristics 32.7.1 normal i/o pins table 32-9. revd and later normal i/o pins characteristics note: 1. these values are based on simulation. these va lues are not covered by test limits in production or characterization. symbol parameter conditions min. typ. max. units r pull pull-up - pull-down resistance i 20 40 60 k v il input low-level voltage v dd =1.62v-2.7v - - 0.25*v dd v v dd =2.7v-3.63v - - 0.3*v dd v ih input high-level voltage v dd =1.62v-2.7v 0.7*v dd - - v dd =2.7v-3.63v 0.55*v dd - - v ol output low-level voltage v dd >1.6v, i ol max i - 0.1*v dd 0.2*v dd v oh output high-level voltage v dd >1.6v, i oh max ii 0.8*v dd 0.9*v dd - i ol output low-level current v dd =1.62v-3v, port.pincfg.drvstr=0 - - 1 ma v dd =3v-3.63v, port.pincfg.drvstr=0 - - 2.5 v dd =1.62v-3v, port.pincfg.drvstr=1 - - 3 v dd =3v-3.63v, port.pincfg.drvstr=1 - - 10 i oh output high-level current v dd =1.62v-3v, port.pincfg.drvstr=0 - - 0.7 v dd =3v-3.63v, port.pincfg.drvstr=0 - - 2 v dd =1.62v-3v, port.pincfg.drvstr=1 - - 2 v dd =3v-3.63v, port.pincfg.drvstr=1 - - 7 t rise rise time (1) load = 20pf, vdd = 3.3v - - 15 ns t fall fall time (1) - - 15 i leak input leakage current pull-up resistors disabled -1 +/-0.015 1 a
571 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 32-10. samd20 revc/revb normal i/o pins characteristics note: 1. these values are based on simulation. these va lues are not covered by test limits in production or characterization. symbol parameter conditions min. typ. max. units r pull pull-up - pull-down resistance i 20 40 60 k v il input low-level voltage v dd =1.62v-2.7v - - 0.25*v dd v v dd =2.7v-3.63v - - 0.3*v dd v ih input high-level voltage v dd =1.62v-2.7v 0.7*v dd - - v dd =2.7v-3.63v 0.55*v dd - - v ol output low-level voltage v dd >1.6v, i ol max i - 0.1*v dd 0.2*v dd v oh output high-level voltage v dd >1.6v, i oh max ii 0.8*v dd 0.9*v dd - i ol output low-level current v dd =1.6v-3v - - 8 ma v dd =3v-3.63v - - 20 i oh output high-level current v dd =1.6v-3v - - 4.5 v dd =3v-3.63v - - 10 t rise rise time (1) load=30pf,vdd=3.3v, slope range [10%- 90%] - 7 - ns t fall fall time (1) - 9.5 - i leak input leakage current pull-up resistors disabled -1 +/-0.015 1 a
572 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.7.2 i 2 c pins refer to ?i/o multiplexing and considerations? on page 11 to get the list of i 2 c pins. table 32-11. i 2 c pins characteristics in i 2 c configuration i 2 c pins timing characteristics can be found in ?sercom in i2c mode timing? on page 598 . 32.7.3 xosc pin xosc pins behave as normal pins when used as normal i/os. refer to table 32-9 . 32.7.4 xosc32 pin xosc32 pins behave as normal pins when used as normal i/os. refer to table 32-9 . 32.7.5 external reset pin reset pin has the same electrical characteristics as normal i/o pins. refer to table 32-9 . symbol parameter condition min. typ. max. units r pull pull-up - pull-down resistance i 20 40 60 k v il input low-level voltage v dd =1.62v-2.7v i - - 0.25*v dd v v dd =2.7v-3.63v - - 0.3*v dd v ih input high-level voltage v dd =1.62v-2.7v 0.7*v dd - - v dd =2.7v-3.63v i 0.55*v dd - - v hys hysteresis of schmitt trigger inputs 0.08*v dd - - v ol output low-level voltage v dd > 2.0v i, i ol =3ma - - 0.4 v dd 2.0v i ol =2ma - - 0.2*v dd i ol output low-level current v ol =0.4v 3 - - ma v ol =0.6v 6 - - f scl scl clock frequency i - - 400 khz
573 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.8 analog characteristics 32.8.1 voltage regulator characteristics table 32-12. voltage regulator electrical characteristics note: supplying any external components using v ddcore pin is not allowed to assure the integrity of the core supply voltage. table 32-13. decoupling requirements 32.8.2 power-on reset (por) characteristics table 32-14. por characteristics figure 32-2. por operating principle symbol parameter conditions min. typ. max. units v ddcore dc calibrated output voltage voltage regulator normal mode 1.1 1.23 1.30 v symbol parameter conditions min. typ. max. units c in input regulator capacitor, between v ddin and gnd i - 1 - f c out output regulator capacitor, between v ddcore and gnd - 1 - f symbol parameter conditions min. typ. max. units v pot+ voltage threshold on v dd rising i v dd falls at 1v/ms or slower 1.27 1.45 1.58 v v pot- voltage threshold on v dd falling 0.72 0.99 1.32 v reset vdd v pot+ v time pot-
574 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.8.3 brown-out detectors characteristics 32.8.3.1 bod33 table 32-15. bod33 level value note: see chapter memories table ?nvm user row mapping? for the bod33 default value settings. table 32-16. bod33 characteristics note: 1. these values are based on simulation. these values are not covered by test limits in production or characterization. 32.8.4 analog-to-digital (adc) characteristics bod33.level conditions min. typ. max. units 6 hysteresis on - 1.715 1.745 v 7 - 1.750 1.779 39 - 2.84 2.92 48 - 3.2 3.3 6 hysteresis off 1.62 1.64 1.67 7 1.64 1.675 1.71 39 2.72 2.77 2.81 48 3.0 3.07 3.2 symbol parameter conditions min. typ. max. units i step size, between adjacent values in bod33.level i - 34 - mv v hyst hysteresis i 35 - 170 mv t det detection time time with v ddana < v th necessary to generate a reset signal - 0.9 (1) - s i bod33 current consumption continuous mode 2.9 33 52.2 a sampling mode - 23 75.5 t startup startup time i - 2.2 (1) - s table 32-17. operating conditions symbol parameter conditions min. typ. max. units res resolution i 8 - 12 bits f clk_adc adc clock frequency i 30 - 2100 khz sample rate (1) single shot 5 - 323 ksps free running 5 - 350 ksps
575 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 notes: 1. these values are based on characterization. these values are not covered by test limits in production. 2. these values are based on simulation. these values are not covered by test limits in production or characterization. 3. in this condition and for a sample rate of 350ksps, 1 c onversion at gain 1x takes 6 clock cycles of the adc clock. table 32-18. differential mode sampling time (1) 0.5 - - cycles conversion time (1) 1x gain - 6 - cycles v ref voltage reference range 1.0 - v ddana -0.6 v v refint1v internal 1v reference (2) - 1.0 - v v refintvcc0 internal ratiometric reference 0 (2) - v ddana /1.48 - v v refintvcc1 internal ratiometric reference 1 (2) v ddana >2.0v - v ddana /2 - v conversion range (1) differential mode -v ref /gain - +v ref /gain v single-ended mode 0.0 - +v ref /gain v c sample sampling capacitance (2) - 3.5 - pf r sample input channel source resistance (2) - - 3.5 k i dd dc supply current (1) f clk_adc = 2.1mhz i (3) - 1.25 1.79 ma symbol parameter conditions min. typ. max. units enob effective number of bits with gain compensation - 10.5 11.1 bits tue total unadjusted error i 1x gain n 1.5 4.3 15.0 lsb inl i integral non linearity 1x gain n 1.0 1.3 4.5 lsb dnl differential non linearity 1x gain n +/-0.3 +/-0.5 +/-0.95 lsb i gain error ext. ref 1x -10.0 2.5 +10.0 mv i v ref =v ddana /1.48 -15.0 -1.5 +10.0 mv i bandgap -20.0 -5.0 +20.0 mv gain accuracy ext. ref. 0.5x +/-0.1 +/-0.2 +/-0.45 % ext. ref. 2x to 16x +/-0.05 +/-0.1 +/-0.11 % offset error ext. ref. 1x -5.0 -1.5 +5.0 mv v ref =v ddana /1.48 -5.0 0.5 +5.0 mv bandgap -5.0 3.0 +5.0 mv table 32-17. operating conditions (continued) symbol parameter conditions min. typ. max. units
576 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 notes: 1. maximum numbers are based on characterization and not test ed in production, and valid for 5% to 95% of the input voltag e range. 2. dynamic parameter numbers are based on char acterization and not tested in production. 3. respect the input common mode voltage through the following equations (where v cm_in is the input channel common mode voltage): c. if |v in | > v ref /4 z v cm_in < 0.95*v ddana + v ref /4 ? 0.75v z v cm_in > v ref /4 -0.05*v ddana -0.1v d. if |v in | < v ref /4 z v cm_in < 1.2*v ddana - 0.75v z v cm_in > 0.2*v ddana - 0.1v 4. the adc channels on pins pa08, pa09, pa10, pa11 are powered from the vddio power supply. the adc performance of these pins wi ll not be the same as all the other adc channels on pins powered from the vddana power supply. table 32-19. single-ended mode notes: 1. maximum numbers are based on characterization and not test ed in production, and for 5% to 95% of the input voltage rang e. 2. respect the input common mode voltage through the following equations (where v cm_in is the input channel common mode voltage) for all v in : z v cm_in < 0.7*v ddana + v ref /4 ? 0.75v z v cm_in > v ref /4 ? 0.3*v ddana - 0.1v 3. the adc channels on pins pa08, pa09, pa10, pa11 are powered from the vddio power supply. the adc performance of these pins wi ll not be the same as all the other adc channels on pins powered from the vddana power supply. sfdr spurious free dynamic range 1x gain f clk_adc = 2.1mhz f in = 40khz a in = 95%fsr 62.7 70.0 75.0 db sinad signal-to-noise and distortion 54.1 65.0 68.5 db snr signal-to-noise ratio 54.5 65.5 68.6 db thd total harmonic distortion -77.0 -64.0 -63.0 db noise rms t=25c 0.6 1.0 1.6 mv symbol parameter conditions min. typ. max. units symbol parameter conditions min. typ. max. units enob effective number of bits with gain compensation - 9.5 9.8 bits tue total unadjusted error 1x gain - 10.5 14.0 lsb inl integral non-linearity 1x gain 1.0 1.6 3.5 lsb dnl differential non-linearity 1x gain +/-0.5 +/-0.6 +/-0.95 lsb gain error ext. ref. 1x -5.0 0.7 +5.0 mv gain accuracy ext. ref. 0.5x +/-0.2 +/-0.34 +/-0.4 % ext. ref. 2x to 16x +/-0.01 +/-0.1 +/-0.2 % offset error ext. ref. 1x -5.0 1.5 +5.0 mv sfdr spurious free dynamic range 1x gain f clk_adc = 2.1mhz f in = 40khz a in = 95%fsr 63.1 65.0 67.0 db sinad signal-to-noise and distortion 47.5 59.5 61.0 db snr signal-to-noise ratio 48.0 60.0 64.0 db thd total harmonic distortion -65.4 -63.0 -62.1 db noise rms t = 25c - 1.0 - mv
577 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.8.4.1 performance with the averaging digital feature averaging is a feature which increases the sample accuracy. adc automatically computes an average value of multiple consecutive conversions. the numbers of samples to be averaged is specified by the number-of-samples-to-be- collected bit group in the average control register (avgct rl.samplenum[3:0]) and the averaged output is available in the result register (result). table 32-20. averaging feature 32.8.4.2 performance with the hardwa re offset and gain correction inherent gain and offset errors affect the absolute accuracy of the adc. the offset error cancellation is handled by the offset correction register (offsetcorr) and the gain er ror cancellation, by the gain correction register (gaincorr). the offset and gain correction value is subtracted from the converted data before writing the result register (result). table 32-21. offset and gain correction feature 32.8.4.3 inputs and sample and hold acquisition times the analog voltage source must be able to charge the sample and hold (s/h) capacitor in the adc in order to achieve maximum accuracy. seen externally the adc input consists of a resistor ( ) and a capacitor ( ). in addition, the source resistance ( ) must be taken into account when calculating the required sample and hold time. figure 32-3 shows the adc input channel equivalent circuit. average number conditions snr (db) sinad (db) sfdr (db) enob (bits) 1 in differential mode, 1x gain, v ddana =3.0v, v ref =1.0v, 350ksps 66.0 65.0 72.8 9.75 8 67.6 65.8 75.1 10.62 32 69.7 67.1 75.3 10.85 128 70.4 67.5 75.5 10.91 gain factor conditions offset error (mv) gain error (mv) total unadjusted error (lsb) 0.5x in differential mode, 1x gain, v ddana =3.0v, v ref =1.0v, 350ksps 0.25 1.0 2.4 1x 0.20 0.10 1.5 2x 0.15 -0.15 2.7 8x -0.05 0.05 3.2 16x 0.10 -0.05 6.1 r sample c sample r source
578 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 32-3. adc input to achieve n bits of accuracy, the capacitor must be charged at least to a voltage of the minimum sampling time for a given can be found using this formula: for a 12 bits accuracy: where 32.8.5 digital to analog conv erter (dac) characteristics table 32-22. operating conditions (1) notes: 1. these values are based on specifications otherwise noted. 2. these values are based on characte rization. these values are not cove red by test limits in production. r source r sample analog input ainx c sample v in vddana/2 c sample v csample v in 12 n 1 + () ? ? () t samplehold r source t samplehold r sample r + source () c sample () n 1 + () 2 () ln t samplehold r sample r + source () c sample () 9.02 t samplehold 1 2 f adc -------------------- - = symbol parameter conditions min. typ. max. units v ddana analog supply voltage i 1.62 - 3.63 v av ref external reference voltage i 1.0 - v ddana -0.6 v internal reference voltage 1 - 1 - v internal reference voltage 2 - v ddana - v i linear output voltage range i 0.05 - v ddana -0.05 v i minimum resistive load i 5 - - k i maximum capacitance load i - - 100 pf i dd dc supply current (2) voltage pump disabled - 160 230 a
579 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 32-23. clock and timing (1) note: 1. these values are based on simulation. these values are not covered by test limits in production or characterization. note: 1. all values measured using a conversion rate of 350ksps. 32.8.6 analog comparator characteristics table 32-25. elect rical and timing symbol parameter conditions min. typ. max. units conversion rate c load =100pf r load > 5k normal mode - - 350 ksps for data =+/-1 - - 1000 i startup time v ddna > 2.6v - - 2.85 s v ddna < 2.6v - - 10 s table 32-24. accuracy characteristics (1) symbol parameter conditions min. typ. max. units res input resolution i - - 10 bits inl integral non-linearity v ref = ext 1.0v v dd = 1.6v 0.75 1.1 2.5 lsb v dd = 3.6v 0.6 1.2 1.5 v ref = v ddana v dd = 1.6v 1.4 2.2 2.5 v dd = 3.6v 0.9 1.4 1.5 v ref = int1v v dd = 1.6v 0.75 1.3 1.5 v dd = 3.6v 0.8 1.2 1.5 dnl differential non-linearity v ref = ext 1.0v v dd = 1.6v +/-0.9 +/-1.2 +/-1.5 lsb v dd = 3.6v +/-0.9 +/-1.1 +/-1.2 v ref = v ddana v dd = 1.6v +/-1.1 +/-1.5 +/-1.7 v dd = 3.6v +/-1.0 +/-1.1 +/-1.2 v ref = int1v v dd = 1.6v +/-1.1 +/-1.4 +/-1.5 v dd = 3.6v +/-1.0 +/-1.5 +/-1.6 i gain error ext. v ref +/-1.5 +/-5 +/-10 mv i offset error ext. v ref +/-2 +/-3 +/-6 mv symbol parameter conditions min. typ. max. units i positive input voltage range i 0 - v ddana v i negative input voltage range i 0 - v ddana
580 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 notes: 1. according to the standard equation v(x)=v lsb *(x+1); v lsb =v ddana /64 2. data computed with the best fit method 3. data computed using histogram 32.8.7 bandgap reference characteristics table 32-26. bandgap (internal 1. 1v reference) characteristics i offset hysteresis = 0, fast mode -15 0.0 +15 mv hysteresis = 0, low power mode -25 0.0 +25 mv hysteresis hysteresis = 1, fast mode 20 50 80 mv hysteresis = 1, low power mode 15 40 75 mv propagation delay changes for v acm =v ddana /2 100mv overdrive, fast mode - 60 116 ns changes for v acm =v ddana /2 100mv overdrive, low power mode - 225 370 ns t startup startup time enable to ready delay fast mode - 1 2 s enable to ready delay low power mode - 12 19 s v scale inl (3) -1.4 0.75 +1.4 lsb dnl (3) -0.9 0.25 +0.9 lsb offset error (1)(2) -0.200 0.260 +0.920 lsb gain error (1)(2) -0.89 0.215 0.89 lsb symbol parameter conditions min. typ. max. units symbol parameter conditions min. typ. max. units intbg bandgap reference over voltage and [-40, +85]c 1.08 1.1 1.12 v over voltage at 25c 1.09 1.1 1.11
581 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.8.8 temperature sensor characteristics 32.8.8.1 temperature sensor characteristics table 32-27. temperature sensor characteristics (1) ) note: 1. these values are based on characterization. these values are not covered by test limits in production. 2. see also rev c errata concerning the temperature sensor. 32.8.8.2 software-based refinement of the actual temperature the temperature sensor behavior is linear but it depends on several parameters such as the internal voltage reference which itself depends on the temperature. to take this into account, each device contains a temperature log row with data measured and written during the production tests. these cali bration values should be read by software to infer the most accurate temperature readings possible. this software temperature log row can be read at addres s 0x00806030. the software temperature log row cannot be written. this section specifies the temperature log row content and ex plains how to refine the temperature sensor output using the values in the temperature log row. temperature log row all values in this row were measured in the following conditions: z v ddin = v ddio = v ddana = 3.3v z adc clock speed = 1mhz z adc mode: free running mode, adc av eraging mode with 4 averaged samples z adc voltage reference = 1.0v internal reference (aka int1v) z adc input = temperature sensor table 32-28. temperature log row content symbol parameter conditions min. typ. max. units i temperature sensor output voltage t= 25c, v ddana = 3.3v - 0.667 - v i temperature sensor slope 2.3 2.4 2.5 mv/c i variation over v ddana voltage v ddana =1.62v to 3.6v -1.7 1 3.7 mv/v bit position name description 7:0 room_temp_val_int integer part of room temperature in c 11:8 room_temp_val_dec decimal part of room temperature 19:12 hot_temp_val_int integer part of hot temperature in c 23:20 hot_temp_val_dec decimal part of hot temperature 31:24 room_int1v_val 2?s complement of the internal 1v reference drift at room temperature (versus a 1.0 centered value)
582 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 the temperature sensor values are logged during te st production flow for room and hot insertions: z room_temp_val_int and room_temp_val_dec cont ains the measured temperature at room insertion (e.g. for room_temp_val_int=25 and room_temp_val_dec=2, the measured temperature at room insertion is 25.2c). z hot_temp_val_int and hot_temp_v al_dec contains the measured temperature at hot insertion (e.g. for hot_temp_val_int=83 and hot_temp_va l_dec=3, the measured temperature at room insertion is 83.3c). the temperature log row also contains the corresponding 12bit adc conversions of both room and hot temperatures: z room_adc_val contains the 12bit adc value corresponding to (room_temp_val_int, room_temp_val_dec) z hot_adc_val contains the 12bit adc value corresponding to (hot_temp_val_int, hot_temp_val_dec) the temperature log row also contains the corresponding 1v internal reference of both room and hot temperatures: z room_int1v_val is the 2?s complement of the internal 1v reference value corresponding to (room_temp_val_int, room_temp_val_dec) z hot_int1v_val is the 2?s complement of the internal 1v reference value corresponding to (hot_temp_val_int, hot_temp_val_dec) z room_int1v_val and hot_int1v_val values are centered around 1v with a 0.001v step. in other words, the range of values [0,127] corresponds to [1v, 0.873v] and the range of values [-1, -127] corresponds to [1.001v, 1.127v]. int1v == 1 - (val/1000) is valid for both ranges. using linear interpolation for concise equations, we?ll use the following notations: z (room_temp_val_int, room_temp_val_dec) is denoted temp r z (hot_temp_val_int, hot_temp_val_dec) is denoted temp h z room_adc_val is denoted adc r , its conversion to volt is denoted v adcr z hot_adc_val is denoted adc h , its conversion to volt is denoted v adch z room_int1v_val is denoted int1v r z hot_int1v_val is denoted int1v h using the (temp r , adc r ) and (temp h , adc h ) points, using a linear interpolation we have the following equation: 39:32 hot_int1v_val 2?s complement of the internal 1v reference drift at hot temperature (versus a 1.0 centered value) 51:40 room_adc_val temperature sensor 12bit adc conversion at room temperature 63:52 hot_adc_val temperature sensor 12bit adc conversion at hot temperature bit position name description
583 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 given a temperature sensor adc conversion value adc m , we can infer a coarse value of the temperature temp c as: [equation 1] note 1: in the previous expression, we?ve added the conv ersion of the adc register value to be expressed in v note 2: this is a coarse value because we assume int1v=1v for this adc conversion. using the (temp r , int1v r ) and (temp h , int1v h ) points, using a linear interpolation we have the following equation: then using the coarse temperature value, we can infer a closer to reality int1v value during the adc conversion as: v adc v adcr ? temp temp r ? ------------------- ------------------- - ?? ?? ?? v adch v adcr ? temp h temp r ? ------------------- ----------------------- - ?? ?? ?? = temp c temp r adc m 1 2 12 1 ? () --------------------- - ? ?? ?? ?? adc r int 1 v r 2 12 1 ? () --------------------- - ? ?? ?? ?? ? ?? ?? ?? ?? ?? temp h temp r ? () ? adc h int 1 v h 2 12 1 ? () --------------------- - ? ?? ?? ?? adc r int 1 v r 2 12 1 ? () --------------------- - ? ?? ?? ?? ? ?? ?? ?? ------------------------------- ------------------------------------ ----------------------------------- ------------------------- ------------------------------- + = int 1 vint 1 v r ? temp temp r ? --------------------- ---------------------- - ?? ?? ?? int 1 v h int 1 v r ? temp h temp r ? ------------------------ ----------------------- - ?? ?? ?? =
584 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 back to [equation 1], we replace int1v=1v by int1v = int1v m , we can then deduce a finer temperature value as: [equation 1bis] int 1 v m int 1 v r int 1 v h int 1 v r ? () temp c temp r ? () ? temp h temp r ? () ------------------------- ----------------------------- ------------------------------ ---------------- ?? ?? ?? + = temp f temp r adc m int 1 v m 2 12 1 ? () --------------------- - ? ?? ?? ?? adc r int 1 v r 2 12 1 ? () --------------------- - ? ?? ?? ?? ? ?? ?? ?? temp h temp r ? () ? adc h int 1 v h 2 12 1 ? () --------------------- - ? ?? ?? ?? adc r int 1 v r 2 12 1 ? () --------------------- - ? ?? ?? ?? ? ?? ?? ?? --------------------------------- ----------------------------------- ----------------------------- ------------------------------ ------------------------------- + =
585 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.9 nvm characteristics table 32-29. maximum operating frequency note that on this flash technology, a max number of 8 consecutive write is allowed per row. once this number is reached, a row erase is mandatory. table 32-30. flash endurance and data retention note: 1. an endurance cycle is a write and an erase operation. table 32-31. eeprom emulation (1) endurance and data retention notes: 1. the eeprom emulation is a software emulation described in the app note at03265. 2. an endurance cycle is a write and an erase operation. v dd range nvm wait states maximum operating frequency units 1.62v to 2.7v 0 14 mhz 1 28 2 42 3 48 2.7v to 3.63v 0 24 1 48 symbol parameter conditions min. typ. max. units ret nvm25k retention after up to 25k average ambient 55c 10 50 - years ret nvm2.5k retention after up to 2.5k average ambient 55c 20 100 - years ret nvm100 retention after up to 100 average ambient 55c 25 >100 - years cyc nvm cycling endurance (1) -40c < ta < 85c 25k 150k - cycles symbol parameter conditions min. typ. max. units ret eeprom100k retention after up to 100k average ambient 55c 10 50 - years ret eeprom10k retention after up to 10k average ambient 55c 20 100 - years cyc eeprom cycling endurance (2) -40c < ta < 85c 100k 600k - cycles table 32-32. nvm characteristics symbol parameter conditions min. typ. max. units t fpp page programming time - - - 2.5 ms t fre row erase time i - - - 6 ms t fce dsu chip erase time (chip_erase) - - - 240 ms
586 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.10 oscillators characteristics 32.10.1 crystal oscillator (xosc) characteristics 32.10.1.1 digital clock characteristics the following table describes the characteristics for the oscillator when a digital clock is applied on xin. table 32-33. digital clock characteristics 32.10.1.2 crystal oscillator characteristics the following table describes the characteristics for the o scillator when a crystal is connected between xin and xout as shown in figure 32-4 . the user must choose a crystal oscillator where the crystal load capacitance c l is within the range given in the table. the exact value of c l can be found in the crystal datasheet. the capacitance of the external capacitors (c lext ) can then be computed as follows: where c stray is the capacitance of the pins and pcb, c shunt is the shunt capacitance of the crystal. table 32-34. crystal oscillator characteristics symbol parameter conditions min. typ. max. units f cpxin xin clock frequency i - - 32 mhz symbol parameter conditions min. typ. max. units f out crystal oscillator frequency i 0.4 - 32 mhz esr crystal equivalent series resistance safety factor = 3 the agc doesn?t have any noticeable impact on these measurements. f = 0.455mhz, c l = 100pf xosc.gain = 0 - - 5.6k f = 2mhz, c l = 20pf xosc.gain = 0 - - 416 f = 4mhz, c l = 20pf xosc.gain = 1 - - 243 f = 8mhz, c l = 20pf xosc.gain = 2 - - 138 f = 16mhz, c l = 20pf xosc.gain = 3 - - 66 f = 32mhz, c l = 18pf xosc.gain = 4 - - 56 c xin parasitic capacitor load i - 5.9 - pf c xout parasitic capacitor load - 3.2 - pf c lext 2c l c stray c shunt ? ? () =
587 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 32-4. oscillator connection current consumption f = 2mhz, c l = 20pf, agc off 27 65 85 a f = 2mhz, c l = 20pf, agc on 14 52 73 f = 4mhz, c l = 20pf, agc off 61 117 150 f = 4mhz, c l = 20pf, agc on 23 74 100 f = 8mhz, c l = 20pf, agc off 131 226 296 f = 8mhz, c l = 20pf, agc on 56 128 172 f = 16mhz, c l = 20pf, agc off 305 502 687 f = 16mhz, c l = 20pf, agc on 116 307 552 f = 32mhz, c l = 18pf, agc off 1031 1622 2200 f = 32mhz, c l = 18pf, agc on 278 615 1200 t startup startup time f = 2mhz, c l = 20pf, xosc.gain = 0, esr = 600 - 14k 48k cycles f = 4mhz, c l = 20pf, xosc.gain = 1, esr = 100 - 6800 19.5k f = 8mhz, c l = 20pf, xosc.gain = 2, esr = 35 - 5550 13k f = 16mhz, c l = 20pf, xosc.gain = 3, esr = 25 - 6750 14.5k f = 32mhz, c l = 18pf, xosc.gain = 4, esr = 40 - 5.3k 9.6k symbol parameter conditions min. typ. max. units c shunt l m r m c m c stray c lext c lext xin crystal xout
588 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.10.2 external 32khz crystal oscillator (xosc32k) characteristics 32.10.2.1 digital clock characteristics the following table describes the characteristics for the oscillator when a digital clock is applied on xin32 pin. table 32-35. digital clock characteristics 32.10.2.2 crystal oscillator characteristics figure 32-4 and the equation in ?crystal oscillator characteristics? on page 586 also applies to the 32khz oscillator connection. the user must choose a crystal oscillator where the crystal load capacitance c l is within the range given in the table. the exact value of c l can be found in the crystal datasheet. note: 1. see revd/revc/revb errata concerning the xosc32k. 32.10.3 digital frequency locke d loop (dfll48m) characteristics table 32-37. dfll48m characteristics (2) symbol parameter conditions min. typ. max. units f cpxin32 xin32 clock frequency i - 32.768 - khz i xin32 clock duty cycle i - 50 - % table 32-36. 32khz crystal oscillator characteristics symbol parameter conditions min. typ. max. units f out crystal oscillator frequency i - 32768 - hz t startup startup time esr xtal = 39.9k , c l = 12.5pf - 28k 30k cycles c l crystal load capacitance i - - 12.5 pf c shunt crystal shunt capacitance i - 0.1 - c xin32 parasitic capacitor load tqfp64/48/32 packages - 3.1 - c xout32 parasitic capacitor load - 3.3 - i xosc32k current consumption agc off - 1.22 2.19 a agc on (1) - - - esr crystal equivalent series resistance f=32.768khz safety factor = 3 c l =12.5pf - - 141 k symbol parameter conditions min. typ. max. units f out output frequency i open loop after calibration at room temperature 47 48 49 mhz f ref reference frequency i 0.732 32.768 33 khz maximum fine step size (1) open loop - - 0.15 % maximum coarse step size (1) open loop - - 2.5
589 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 note: 1. these values are based on simulation. these values are not covered by test limits in production or characterization 2. see revc/revb errata concerning the dfll48m. 32.10.4 32.768khz internal oscillator (osc32k) characteristics table 32-38. 32khz rc oscillator characteristics 32.10.5 ultra low power internal 32khz rc oscillator (osculp32k) characteristics table 32-39. ultra low power internal 32khz rc oscillator characteristics i dfll power consumption on v ddana open loop, coarse calibrated against 48mhz, fine=128 - 100 - a t startup startup time open loop after calibration against 48mhz f out within 90% of final value - 8 - s t lfine fine lock time quick lock disabled, chill cycle disabled, cstep=3,fstep=1, f ref = 32.768khz - 600 - symbol parameter conditions min. typ. max. units symbol parameter conditions min. typ. max. units f out output frequency calibrated against a 32.768khz reference at 25c, over [-40, +85]c, over [1.62, 3.63]v 28.508 32.768 34.734 khz calibrated against a 32.768khz reference at 25c, at v dd =3.3v 32.276 32.768 33.260 calibrated against a 32.768khz reference at 25c, over [1.62, 3.63]v 31.457 32.768 34.079 i osc32k current consumption i - 0.67 1.31 a t startup startup time i - 1 2 cycle duty duty cycle i - 50 - % symbol parameter conditions min. typ. max. units f out output frequency calibrated against a 32.768khz reference at 25c, over [-40, +85]c, over [1.62, 3.63]v 25.559 32.768 38.011 khz calibrated against a 32.768khz reference at 25c, at v dd =3.3v 31.293 32.768 34.570 calibrated against a 32.768khz reference at 25c, over [1.62, 3.63]v 31.293 32.768 34.570
590 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 notes: 1. these values are based on simulation. these values are not covered by test limits in production or characterization. 2. this oscillator is always on. 32.10.6 8mhz rc oscillator (osc8m) characteristics table 32-40. internal 8mhz rc oscillator characteristics i osculp32k (1)(2) - - 125 na t startup startup time i - 10 - cycles duty duty cycle i - 50 - % symbol parameter conditions min. typ. max. units symbol parameter conditions min. typ. max. units f out output frequency i calibrated against a 8mhz reference at 25c, over [-40, +85]c, over [1.62, 3.63]v 7.8 8 8.16 mhz calibrated against a 8mhz reference at 25c, at v dd =3.3v 7.94 8 8.06 calibrated against a 8mhz reference at 25c, over [1.62, 3.63]v 7.92 8 8.08 i osc8m current consumption iidle idle2 on osc32k versus idle2 on calibrated osc8m enabled at 8mhz (frange=1, presc=0) 34.5 71 96 a t startup startup time i - 2.1 3 s duty duty cycle i - 50 - %
591 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.11 ptc typical characteristics figure 32-5. power consumption [a]. 1 sensor, noise countermeasures disabled, f=48mhz, vcc=3.3v figure 32-6. power consumption [a]. 1 sensor, noise countermeasur es enabled, f=48mhz, vcc=3.3v 0 20 40 60 80 100 120 140 1 2 4 8 16 32 64 sample averaging scan rate 10ms scan rate 50ms scan rate 100ms scan rate 200ms 0 20 40 60 80 100 120 140 160 180 200 1 2 4 8 16 32 64 sample averaging scan rate 10ms scan rate 50ms scan rate 100ms scan rate 200ms
592 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 32-7. power consumption [a]. 10 sensors, noise countermeasur es disabled, f=48mhz, vcc=3.3v figure 32-8. power consumption [a]. 10 sensors, noise countermeasur es enabled, f=48mhz, vcc=3.3v 0 200 400 600 800 1000 1200 1248163264 sample averaging scan rate 10ms scan rate 50ms scan rate 100ms scan rate 200ms linear (scan rate 50ms) 0 100 200 300 400 500 600 700 800 900 1 2 4 8 16 32 64 sample averaging scan rate 10ms scan rate 50ms scan rate 100ms scan rate 200ms
593 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 32-9. power consumption [a]. 100 sensors, noise countermeasur es disabled, f=48mhz, vcc=3.3v figure 32-10.power consumption [a]. 100 sensors, noise countermeasur es enabled, f=48mhz, vcc=3.3v 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 1248163264 sample averaging scan rate 10ms scan rate 50ms scan rate 100ms scan rate 200ms 0 200 400 600 800 1000 1200 1400 1600 1800 1 2 4 8 16 32 64 sample averaging scan rate 10ms scan rate 50ms scan rate 100ms scan rate 200ms
594 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 32-11.cpu utilization. 0 % 10 % 20 % 30 % 40 % 50 % 60 % 70 % 80 % 10 50 100 200 channel count 1 channel count 10 channel count 100
595 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.12 timing characteristics 32.12.1 external reset table 32-41. external reset characteristics 32.12.2 sercom in spi mode timing figure 32-12.spi timing requirements in master mode symbol parameter condition min. typ. max. units t ext minimum reset pulse width i 10 - - ns msb lsb b s l b s m t mos t mis t mih t sckw t sck t moh t moh t sckf t sckr t sckw mo si (data output) mi so (data input) sck (cpol = 1) sck (cpol = 0) ss
596 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 32-13.spi timing requirements in slave mode msb lsb b s l b s m t sis t sih t ssckw t ssckw t ssck t ssh t sosh t ssckr t ssckf t sos t sss t soss miso (da ta output) mo si ( data input) sck ( cpol = 1) sck ( cpol = 0) ss
597 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table 32-42. spi timing characteristics and requirements (1) note: 1. these values are based on simulation. these va lues are not covered by test limits in production. 2. see ?i/o pin characteristics? on page 570 symbol parameter conditions min. typ. max. units t sck sck period master refer to section 25.6.2.3 clock generation ns t sckw sck high/low width master - 0.5*t sck - t sckr sck rise time (2) master - - - t sckf sck fall time (2) master - - - t mis miso setup to sck master - 29 - t mih miso hold after sck master - 8 - t mos mosi setup sck master - t sck /2 - 16 - t moh mosi hold after sck master - 16 - t ssck slave sck period slave 1*t clk_apb - - t ssckw sck high/low width slave 0.5*t ssck - - t ssckr sck rise time (2) slave - - - t ssckf sck fall time (2) slave - - - t sis mosi setup to sck slave t ssck /2 - 19 - - t sih mosi hold after sck slave t ssck /2 - 5 - - t sss ss setup to sck slave preloaden=1 2*t clk_apb + t sos - - preloaden=0 t sos +7 - - t ssh ss hold after sck slave t sih - 4 - - t sos miso setup sck slave - t ssck /2 - 20 - t soh miso hold after sck slave - 20 - t soss miso setup after ss low slave - 16 - t sosh miso hold after ss high slave - 11 -
598 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.12.3 sercom in i 2 c mode timing table 32-43 describes the requirements for devices connected to the i 2 c interface bus. timing symbols refer to figure 32-14 . figure 32-14.i 2 c interface bus timing table 32-43. i 2 c interface timing (1) note: 1. these values are based on simulation. these val ues are not covered by test limits in production. 2. cb = capacitive load on each bus line. otherwise noted, value of c b set to 20pf. 3. these values are based on characte rization. these values are not cove red by test limits in production. symbol parameter conditions min. typ. max. units t r rise time for both sda and scl (3) i - - 300 ns t of output fall time from v ihmin to v ilmax (3) 10pf < c b (2) < 400pf 7.0 10.0 50.0 t hd;sta hold time (repeated) start condition f scl > 100khz, master t low -9 - - t low low period of scl clock f scl > 100khz 113 - - t buf bus free time between a stop and a start condition f scl > 100khz t low - - t su;sta setup time for a rep eated start condition f scl > 100khz, master t low +7 - - t hd;dat data hold time f scl > 100khz, master 9 - 12 t su;dat data setup time f scl > 100khz, master 104 - - t su;sto setup time for stop condition f scl > 100khz, master t low +9 - - t su;dat;rx data setup time (receive mode) f scl > 100khz, slave 51 - 56 t hd;dat;tx data hold time (send mode) f scl > 100khz, slave 71 90 138 t su;sta t low t high t low t of t hd;sta t hd;dat t su;dat t su;sto t buf scl t r sda
599 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.12.4 swd timing figure 32-15.swd interface signals table 32-44. swd timings (1) note: 1. these values are based on simulation. these values are not covered by test limits in production or characterization. symbol parameter conditions min. max. units thigh swdclk high period v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 10 500000 ns tlow swdclk low period 10 500000 to s swdio output skew to falling edge swdclk -5 5 tis input setup time required between swdio 4 - tih input hold time required between swdio and rising edge swdclk 1 - stop park tri state acknowledge tri state tri state parity sta rt data data stop park tri state acknowledge tri state sta rt r ead cycle w rite cycle tos thigh tlow tis data data parity tri state tih fr o m debugger to swdio pin fr o m debugger to s wdclk pin s wdio pin to debugger fr o m debugger to swdio pin fr o m debugger to s wdclk pin s wdio pin to debugger
600 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33. packaging information 33.1 thermal considerations 33.1.1 thermal resistance data table 33-1 summarizes the thermal resistance data depending on the package. table 33-1. thermal resistance data 33.1.2 junction temperature the average chip-junction temperature, t j , in c can be obtained from the following equations: equation 1 equation 2 where: z ja = package thermal resistance, junction-to-ambient (c/w), provided in table 33-1 z jc = package thermal resistance, junction-to-case thermal resistance (c/w), provided in table 33-1 z heatsink = cooling device thermal resistance (c/w), provided in the manufacturer datasheet z p d = device power consumption (w) z t a = ambient temperature (c) from ?equation 1? , the user can derive the estimated lifetime of the chip and decide if a cooling device is necessary or not. if a cooling device is to be fitted on the chip, ?equation 2? should be used to compute the resulting average chip- junction temperature t j in c. package type ja jc 32-pin tqfp 68 c/w 25.8 c/w 48-pin tqfp 78.8 c/w 12.3 c/w 64-pin tqfp 66.7 c/w 11.9 c/w 32-pin qfn 37.2 c/w 3.1 c/w 48-pin qfn 33 c/w 11.4 c/w 64-pin qfn 33.5 c/w 11.2 c/w t j t a p d ja () + = t j t a p d heatsink jc + () () + =
601 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33.2 package drawings 33.2.1 64-pin tqfp table 33-2. device and package maximum weight table 33-3. package characteristics table 33-4. package reference 300 mg moisture sensitivity level msl3 jedec drawing reference ms-026 jesd97 classification e3
602 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33.2.2 64-pin qfn note: the exposed die attached pad is not connected inside the device. table 33-5. device and package maximum weight table 33-6. package characteristics table 33-7. package reference 200 mg moisture sensitivity level msl3 jedec drawing reference mo-220 jesd97 classification e3
603 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33.2.3 48-pin tqfp table 33-8. device and package maximum weight table 33-9. package characteristics table 33-10. package reference 140 mg moisture sensitivity level msl3 jedec drawing reference ms-026 jesd97 classification e3
604 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33.2.4 48-pin qfn note: the exposed die attached pad is not connected inside the device. table 33-11. device and package maximum weight table 33-12. package characteristics table 33-13. package reference 140 mg moisture sensitivity level msl3 jedec drawing reference mo-220 jesd97 classification e3
605 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33.2.5 32-pin tqfp table 33-14. device and package maximum weight table 33-15. package characteristics table 33-16. package reference 100 mg moisture sensitivity level msl3 jedec drawing reference ms-026 jesd97 classification e3
606 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33.2.6 32-pin qfn note: the exposed die attached pad is connected inside the device to gnd and gndana connected together. table 33-17. device and package maximum weight table 33-18. package characteristics table 33-19. package reference 90 mg moisture sensitivity level msl3 jedec drawing reference mo-220 jesd97 classification e3
607 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 33.3 soldering profile table table 33-20 gives the recommended soldering profile from j-std-20. table 33-20. soldering profile a maximum of three reflow passes is allowed per component. ___ rev ___251178 profile feature green package average ramp-up rate (217c to peak) 3c/s max. preheat temperature 175c 25c 150-200c time maintained above 217c 60-150s time within 5c of actual peak temperature 30s peak temperature range 260c ramp-down rate 6c/s max time 25c to peak temperature 8 minutes max.
608 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 34. schematic checklist 34.1 introduction this chapter describes a common checklist which should be used when starting and reviewing the schematics for a sam d20 design . this chapter illustrates a recommended power s upply connection, how to connect external analog references, programmer, debugger, oscillator and crystal. 34.2 power supply the sam d20 supports a single power supply from 1.62 to 3.63v. 34.2.1 power supply connections figure 34-1. power supply schematic table 34-1. power supply connections, v ddcore from internal regulator signal name recommended pin connection description v ddio 1.6v to 3.6v decoupling/filtering capacitors 100nf (1)(2) and 10f (1) decoupling/filtering inductor 10h (1)(3) digital supply voltage v ddana 1.6v to 3.6v decoupling/filtering capacitors 100nf (1)(2) and 10f (1) ferrite bead (4) prevents the v dd noise interfering the v ddana analog supply voltage vddana gndana vddin vddio vddcore gnd 100nf 100nf 100nf 1.62v-3.63v 10f 100nf 10f close to device (for every pin)
609 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 notes: 1. these values are only given as typical examples. 2. decoupling capacitor should be placed close to the device for each supply pin pair in the signal group, low esr caps should be used for better decoupling. 3. an inductor should be added between the external power and the v dd for power filtering. 4. ferrite bead has better filtering performance than the common inductor at high frequencies. it can be added between v dd and v ddana for preventing digital noise from entering the analog power domain. the bead should provide enough impedance (e.g. 50 at 20mhz and 220 at 100mhz) for separating the digital power from the analog power domain. make sure to select a ferrite bead designed for filtering applications with a low dc resistance to avoid a large voltage drop across the ferrite bead. 34.3 external analog reference connections the following schematic checklist is only necessary if t he application is using one or more of the external analog references. if the internal references are used instead, the following circuits in figure 34-2 and figure 34-3 are not necessary . figure 34-2. external analog reference schematic with two references v ddcore 1.6v to 1.8v decoupling/filtering capacitor 100nf (1)(2) core supply voltage / external decoupling pin gnd ground gnd ana ground for the analog power domain table 34-1. power supply connections, v ddcore from internal regulator (continued) signal name recommended pin connection description gnd arefa external reference 1 4.7f 100nf gnd arefb external reference 2 4.7f 100nf close to device (for every pin)
610 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 figure 34-3. external analog reference schematic with one reference notes: 1. these values are given as a typical example. 2. decoupling capacitor should be placed close to the device for each supply pin pair in the signal group. table 34-2. external analog reference connections signal name recommended pin connection description arefx 1.0v to v ddana - 0.6v for adc 1.0v to v ddana - 0.6v for dac decoupling/filtering capacitors 100nf (1)(2) and 4.7f (1) external reference from arefx pin on the analog port gnd ground gnd arefa external reference 4.7f 100nf gnd arefb 100nf close to device (for every pin)
611 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 34.4 external reset circuit the external reset circuit is connected to the reset pin when the external reset function is used. if the external reset function has been disabled, the circuit is not necessary. the reset switch can also be removed, if the manual reset is not necessary. the reset pin itself has an internal pull-up resistor, hence it is optional to also add an external pull-up resistor. figure 34-4. external reset circuit example schematic a pull-up resistor makes sure that the reset does not go low unintended causing a device reset. an additional resistor has been added in series with the switch to safely discharge the filtering capacitor, i.e. preventing a current surge when shorting the filtering capacitor which again causes a noise spike that can have a negative effect on the system. notes: 1. these values are given as a typical example. 2. the sam d20 features an internal pull-up resistor on the reset pin, hence an external pull-up is optional. 34.5 unused or unconnected pins unused or unconnected pins (unless marked as nc where applicable) should not be left unconnected and floating. floating pins will add to the overall power consumption of t he device. to prevent this one should always draw the pin voltage towards a given level, either v dd or gnd, through a pull up/down resistor. external or internal pull up/down table 34-3. reset circuit connections signal name recommended pin connection description reset reset low level threshold voltage v ddio = 1.6v - 2.0v: below 0.33 * v ddio v ddio = 2.7v - 3.6v: below 0.36 * v ddio decoupling/filter capacitor 100nf (1) pull-up resistor 10k (1)(2) resistor in series with the switch 330 (1) reset pin gnd reset 100nf 10k v dd 330
612 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 resistors can be used, e.g. the pins can be configured in pull-up or pull-down mode eliminating the need for external components, for more information see ?port? on page 280 for details. there are no obvious benefit in choosing external vs. internal pull resistors. 34.6 clocks and crystal oscillators the sam d20 can be run from internal or external clock source s, or a mix of internal and external sources. an example of usage will be to use the internal 8mhz oscillator as source for the system clock, and an external 32.768khz watch crystal as clock source for the real-time counter (rtc). 34.6.1 external clock source figure 34-5. external clock source example schematic 34.6.2 crystal oscillator figure 34-6. crystal oscillator example schematic the crystal should be located as close to the device as possible. long signal lines may cause too high load to operate the crystal, and cause crosstalk to other parts of the system. table 34-5. crystal oscillator checklist notes: 1. these values are given only as typical example. table 34-4. external clock source connections signal name recommended pin connection description xin xin is used as input for an external clock signal input for inverting oscillator pin xout/gpio can be left unconnected or used as normal gpio xout/gpio xin nc/gpio external clock signal name recommended pin connection description xin load capacitor 15pf (1)(2) external crystal between 0.4 to 30mhz xout load capacitor 15pf (1)(2) xout xin 15pf 15pf
613 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 2. decoupling capacitor should be placed close to the device for each supply pin pair in the signal group. 34.6.3 external real time oscillator the low frequency crystal oscillator is optimized for use with a 32.768khz watch crystal. when selecting crystals, load capacitance and crystal?s equivalent series resistance (esr) must be taken into consideration. both values are specified by the crystal vendor . sam d20 oscillator is optimized for very low power consumption, hence close attention should be made when selecting crystals, see table 34-6 for maximum esr recommendations on 9pf and 12.5pf crystals . the low-frequency crystal oscillator provides an internal load capacitance of typical 3.05pf and 3.29pf. crystals with recommended 12.5pf load capacitance can be without external capacitors as shown in figure 34-7 . note: maximum esr is typical value based on characterization. these values are not covered by test limits in production. figure 34-7. external real time o scillator without load capacitor crystals specifying load capacitance (cl) higher than 12.5pf , require external capacitors applied as described in figure 34-8 . to find suitable load capacitance for a 32.768khz crystal, consult the crystal datasheet. figure 34-8. external real time oscillator with load capacitor notes: 1. these values are given only as typical examples. 2. decoupling capacitor should be placed close to the device for each supply pin pair in the signal group. table 34-6. maximum esr recommen dation for 32.768khz crystal crystal c l (pf) max esr [k ] 12.5 313 table 34-7. external real ti me oscillator checklist signal name recommended pin connection description xin32 load capacitor 22pf (1)(2) timer oscillator input xout32 load capacitor 22pf (1)(2) timer oscillator output xout32 xin32 32.768khz xout32 xin32 32.768khz 22pf 22pf
614 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 34.6.4 calculating the correct crystal decoupling capacitor in order to calculate correct load capacitor fo r a given crystal one can use the model shown in figure 34-9 which includes internal capacitors c ln , external parasitic capacitance c eln and external load capacitance c pn . figure 34-9. crystal circui t with internal, external and parasitic capacitance using this model the total capacitive load for the crystal can be calculated as shown in the equation below: where c tot is the total load capacitance seen by the crystal, this value should be equal to the load capacitance value found in the crystal manufacturer datasheet. the parasitic capacitance c eln can in most applications be disregarded as these are usually very small. if accounted for the value is dependent on the pcb material and pcb layout. for some crystal the internal capacitive load provided by the device itself can be enough. to calculate the total load capacitance in this case. c eln and c pn are both zero, c l1 = c l2 = c l , and the equation reduces to the following: table 34-8 shows the device equivalent internal pin capacitance. xout internal c el1 c l1 c l2 c p1 c p2 c el2 external xin c tot c l 1 c p 1 c el 1 ++ ) c l 2 c p 2 c el 2 ++ ) ( ( c l 1 c p 1 c el 1 c l 2 c p 2 c el 2 ++ +++ ---------------------------- ----------------------------- ------------------------------ ----------------- = c tot c l 2 ------ - =
615 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 34.7 programming and debug ports for programming and/or debugging the sam d20 the device should be connected using the serial wire debug, swd, interface. currently the swd interface is supported by several atmel and third party programmers and debuggers, like the sam-ice, jtagice3 or sam d20 xplained pro (sam d20 evaluation kit) embedded debugger. refer to the sam-ice, jtagice3 or sam d20 xplained pro user guides for details on debugging and programming connections and options. for connecting to any other programming or debugging tool, refer to that specific programmer or debugger?s user guide. the sam d20 xplained pro evaluation board for t he sam d20 supports programming and debugging through the onboard embedded debugger so no external programmer or debugger is needed. 34.7.1 cortex debug connector (10-pin) for debuggers and/or programmers that support the cortex debug connector (10-pin) interface the signals should be connected as shown in figure 34-10 with details described in table 34-9 . figure 34-10.cortex debug connector (10-pin) table 34-9. cortex debug connector (10-pin) table 34-8. equivalent internal pin capacitance symbol value description c xin32 3.05pf equivalent internal pin capacitance c xout32 3.29pf equivalent internal pin capacitance header signal name description swdclk serial wire clock pin swdio serial wire bidirectional data pin 1 vtref gnd gnd nc nc swdio swdclk nc nc nreset cortex debug connector (10-pin) gnd swdio swclk reset v dd
616 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 reset target device reset pin, active low vtref target voltage sense, should be connected to the device v dd gnd ground header signal name description
617 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 34.7.2 10-pin jtagice3 compatible serial wire debug interface the jtagice3 debugger and programmer does not support the cortex debug connector (10-pin) directly, hence a special pinout is needed to directly connect the sam d20 to the jtagice3, alternatively one can use the jtagice3 squid cable and manually match the signals between the jtagice3 and sam d20. figure 34-11 describes how to connect a 10-pin header that support connecting the jtagice3 directly to the sam d20 without the need for a squid cable. to connect the jtagice3 programmer and debugger to the sam d2 0, one can either use the jtagice3 squid cable, or use a 10-pin connector as shown in figure 34-11 with details given in table 34-10 to connect to the target using the jtagice3 50 mil cable directly. figure 34-11.10-pin jtagice3 compat ible serial wire debug interface table 34-10. 10-pin jtagice3 compatible serial wire debug interface header signal name description swdclk serial wire clock pin swdio serial wire bidirectional data pin reset target device reset pin, active low vtg target voltage sense, should be connected to the device v dd gnd ground vtg gnd nc nc swdio swdclk nc nc reset 10-pin jtagice3 compatible serial wire debug header gnd swdio swclk reset v dd 1 nc
618 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 34.7.3 20-pin idc jtag connector for debuggers and/or programmers that support the 20-pin idc jt ag connector, e.g. the sam-ice, the signals should be connected as shown in figure 34-12 with details described in table 34-11 . figure 34-12.20-pin idc jtag connector table 34-11. 20-pin idc jtag connector header signal name description swdclk serial wire clock pin swdio serial wire bidirectional data pin nreset target device reset pin, active low vcc target voltage sense, should be connected to the device v dd gnd ground gnd* these pins are reserved for firmware extension pur poses. they can be left open or connected to gnd in normal debug environment. they are not essential for swd in general. 1 vcc nc nc swdio swdclk nc nc nreset nc nc nc gnd gnd gnd gnd gnd gnd* gnd* gnd* gnd* 20-pin idc jtag connector gnd swdio swclk reset v dd
619 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 35. errata 35.1 revision d 35.1.1 nvmctrl 1 - when the part is secured and ee prom emulation area configured to none, the crc32 is not executed on the en tire flash area but up to the on- chip flash size minus half a row. errata reference: 11988 fix/workaround: when using crc32 on a protected device with eeprom emulation area configured to none, compute the reference crc32 value to the full chip flash size minus half row. 35.1.2 device 1 - after a clock failure detection (i ntflag.cfd = 1), if intflag.cfd is cleared while the clock is still broken, the system is stuck. errata reference: 12687 fix/workaround: after a clock failure detection, do not clear intflag.cfd or perform a system reset. 2 - clock failure detection for externa l osc does not work in standby mode. errata reference: 12688 fix/workaround: before entering standby mode, move the cpu clock to an internal rc, disable external osc and disable the clock failure detector. upon cpu wakeup, restart external osc (if it does not start, the failure occurred during standby), enable the clock failure detector and move the cpu clock to the external osc. 3 - if apb clock is stopped and gclk clock is running, apb read access to read-synchronized registers will fr eeze the system. the cpu and the dap ahb-ap are stalled, as a consequen ce debug operation is impossible. errata reference: 10416 fix/workaround: do not make read access to read-synchronized registers when apb clock is stopped and gclk is running. to recover from this situation, power cycle the device or reset the device using the resetn pin. 4 - digital pin outputs from timer/counters, ac (analog comparator), gclk (generic clock controller), and sercom (i2c and spi) do not change value during standby sleep mode. errata reference: 12537 fix/workaround:
620 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 set the voltage regulator in normal mode before entering standby sleep mode in order to keep digital pin output enabled. this is done by setting the runstdby bit in the vreg register. 5 - if the external xosc32k is broken , neither the external pin rst nor the gclk software reset can reset the gclk generators using xosc32k as source clock. errata reference: 12164 fix/workaround: do a power cycle to reset the gclk generators after an external xosc32k failure. 35.1.3 pm 1 - in debug mode, if a watchdog r eset occurs, the debug session is lost. errata reference: 12196 fix/workaround: a new debug session must be restart after a watchdog reset. 35.1.4 xosc32k 1 - the automatic amplitude control of the xosc32k does not work. errata reference: 10933 fix/workaround: use the xosc32k with automatic amplitude control disabled (xosc32k.aampen = 0) 35.1.5 dfll48m 1 - the dfll clock must be requested before being configured otherwise a write access to a dfll register can freez e the device. errata reference: 9905 fix/workaround: write a zero to the dfll ondemand bi t in the dfllctrl register before configuring the dfll module. 2 - if the dfll48m reaches the maxi mum or minimum coarse or fine calibration values during the locking se quence, an out of bounds interrupt will be generated. these interrupts will be generated even if the final calibration values at dfll48m lock ar e not at maximum or minimum, and might therefore be false out of bounds in terrupts. errata reference: 10669 fix/workaround: check that the lockbits: dflllckc and dflllckf in the sysctrl interrupt flag status and clear register (intflag) are both set before enabling the dflloob interrupt.
621 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 35.2 revision c 35.2.1 nvmctrl 1 - when the part is secured and ee prom emulation area configured to none, the crc32 is not executed on the en tire flash area but up to the on- chip flash size minus half a row. errata reference: 11988 fix/workaround: when using crc32 on a protected device with eeprom emulation area configured to none, compute the reference crc32 value to the full chip flash size minus half row. 35.2.2 vreg 1 - with default bit and register settings the device does not work as specified in standby mode if lo ad current exceeds 100a. errata reference: 11082 fix/workaround: set the forceldo bit in the vreg register. 35.2.3 device 1 - the values stored in the nvm soft ware calibration area for the dfll calibration are not valid. errata reference: 12843 fix/workaround: none. 2 - clock failure detection for externa l osc does not work in standby mode. errata reference: 12688 fix/workaround: before entering standby mode, move the cpu clock to an internal rc, disable external osc and disable the clock failure detector. upon cpu wakeup, restart external osc (if it does not start, the failure occurred during standby), enable the clock failure detector and move the cpu clock to the external osc. 3 - if apb clock is stopped and gclk clock is running, apb read access to read-synchronized registers will fr eeze the system. the cpu and the dap ahb-ap are stalled, as a consequen ce debug operation is impossible. errata reference: 10416 fix/workaround: do not make read access to read-synchronized registers when apb clock is stopped and gclk is running. to recover from this situation, power cycle the device or reset the device using the resetn pin.
622 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 4 - the port output driver strength feature is not available. errata reference: 12684 fix/workaround: none 5 - maximum toggle frequency on all pi ns in worst case operating condition is 8mhz. this affects all operations on the pins, including serial communications. errata reference: 10335 fix/workaround: none. 6 - do not enable timers/counters, ac (analog comparator), gclk (generic clock controller), and sercom (i2c a nd spi) to control digital outputs in standby sleep mode. errata reference: 12786 fix/workaround: set the voltage regulator in normal mode before entering standby sleep mode. this is done by setting the runstdby bit in the vreg register. 7 - after a clock failure detection (i ntflag.cfd = 1), if intflag.cfd is cleared while the clock is still broken, the system is stuck. errata reference: 12687 fix/workaround: after a clock failure detection, do not clear intflag.cfd or perform a system reset. 8 - the temperature sensor is not accura te. no value is written into the temperature log row during production test. errata reference: 11731 fix/workaround: none 9 - the dfllval.coarse, dfllval.fine, dfllmul.cstep and dfllmul.fstep bit groups are not corr ectly located in the register map. dfllval.coarse is only 5 bits and located in dfllval[12..8]. dfllval.fine is only 8 bits and lo cated in dfllval[7:0]. dfllmul.cstep is only 5 bits and located in dfllmu l[28:24]. dfllmul.fstep is only 8 bits and located in df llmul[23:16] errata reference: 10988 fix/workaround: dfllval.coarse, dfllval.fine, dfllmul.cstep and dfllmul.fstep should not be used if code compatibility is required with future device revisions. 10 - if the external xosc32k is broken , neither the external pin rst nor the gclk software reset can reset the gclk generators using xosc32k as source clock. errata reference: 12164 fix/workaround:
623 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 do a power cycle to reset the gclk generators after an external xosc32k failure. 35.2.4 pm 1 - in debug mode, if a watchdog r eset occurs, the debug session is lost. errata reference: 12196 fix/workaround: a new debug session must be restart after a watchdog reset. 2 - the systick timer does not generate a wake up signal to the power manager, and therefore cannot be used to wake up the cpu from sleep mode. errata reference: 11012 fix/workaround: none. 35.2.5 gclk 1 - when the gclk generator is enabled (genctrl.genen = 1), set as output (genctrl.oe = 1) and use a divi sion factor of one (gendiv.div = 1 or 0 and genctrl.divsel=0), the gclk_io might not be set to the configured genctrl.oov value af ter disabling the gclk generator (genctrl.genen=0). errata reference: 10716 fix/workaround: disable the oe request of the gclk generator (genctrl.oe = 0) before disabling the gclk generator (genctrl.genen = 0). 2 - the gclk generator clock is st uck when disabling the generator and changing the division factor from on e to a different value while the gclk generator is set as output. when the gclk generator is enabled (genctrl.genen=1), set as output (g enctrl.oe=1) and use a division factor of one (gendiv.div=1 or 0 an d genctrl.divsel=0), if the division factor is written to a value different of one or zero after disabling the gclk generator (genctrl.genen=0), the gclk generator will be stuck. errata reference: 10686 fix/workaround: disable the oe request of the gclk generator (genctrl.oe=0) before disabling the gclk generator (genctrl.genen=0). 3 - when a gclk is locked and the ge nerator used by the locked gclk is not gclk generator 1, issuing a gclk software reset will lock up the gclk with the syncbusy flag always set. errata reference: 10645 fix/workaround: do not issue a gclk swrst or map gclk generator 1 to ""locked"" gclks.
624 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 35.2.6 xosc32k 1 - the automatic amplitude control of the xosc32k does not work. errata reference: 10933 fix/workaround: use the xosc32k with automatic amplitude control disabled (xosc32k.aampen = 0) 35.2.7 dfll48m 1 - if the firmware writes to the dfll mul.mul register in the same cycle as the closed loop mode tries to update it, the fine calibration will first be reset to midpoint and then incremented/d ecremented by the closed loop mode. then the coarse calibration will be pe rformed with the updated fine value. if this happens before the dfll have got a lock, the new fine calibration value can be anything between 128-dfllm ul.fstep and 128+ dfllmul.fstep which could give smaller calibration rang e for the fine calibration. errata reference: 10634 fix/workaround: always wait until the dfll48m has locked before writing the dfllmul.mul register 2 - the dfll clock must be requested before being configured otherwise a write access to a dfll register can freez e the device. errata reference: 9905 fix/workaround: write a zero to the dfll ondemand bi t in the dfllctrl register before configuring the dfll module. 3 - changing the dfllval.fine calibration bits of the dfll48m digital frequency locked loop might result in a short output frequency overshoot. this might occur both in open loop mode while writing dfllval.fine by software and closed loop mode when the dfll automatically adjusts its output frequency. errata reference: 10537 fix/workaround: - when using dfll48m in open loop mode, be sure the dfll48m is not used by any module while dfllval.fine is written. - when using dfll48m in closed loop mode, be sure that dfllctrl.stable is written to 1. the dfll clock should not be used by any modules until the dfll locks are set. if the application requires on-the-fly df ll calibration (temperature/vcc drift compensation), the firmware should perform, either periodically or when the dfll48m frequency differ too much from target frequency (indicated by dfllval.diff), the following: o switch system clock/module clocks to different clock than dfll48m o re-initiate a dfll48m closed loop lock sequence by disabling and re-enabling the dfll48m
625 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 o wait for fine lock (pclksr.dflllckf set to 1) o switch back system clock/module clocks to the dfll48m better accuracy is achieved using a high multiplier for the dfll48m, using a scaled down or slow clock as reference. a multiplier of 6 will have a theoretical worst case frequency deviation from the reference clock of +/- 8.33%. a multiplier of 500 will have a theoretical worst case frequency deviation from the reference clock of +/- 0.1%. 4 - if the dfll48m reaches the maxi mum or minimum coarse or fine calibration values during the locking se quence, an out of bounds interrupt will be generated. these interrupts will be generated even if the final calibration values at dfll48m lock ar e not at maximum or minimum, and might therefore be false out of bounds in terrupts. errata reference: 10669 fix/workaround: check that the lockbits: dflllckc and dflllckf in the sysctrl interrupt flag status and clear register (intflag) are both set before enabling the dflloob interrupt. 35.2.8 evsys 1 - using synchronous or resynchronized paths, some channels (0,3,6,7) detect an overrun on every event even if no overrun condition is present. errata reference: 10895 fix/workaround: - ignore overrun detection bit for channels 0,3,6,7. - use channels 1,2,4,5 if overrun detection is required. 2 - changing the selected generator of a channel can trigger a spurious interrupt/event. errata reference: 10443 fix/workaround: to change the generator of a channel, first write with edgesel written to zero, then perform a second write with edgesel written to its target value. 35.2.9 sercom 1 - the sercom spi ctrla register bit 17 (dopo bit 1) will always be zero, and cannot be changed. therefore th e sercom spi cannot be switched between master and slave mode on th e same di and do pins. errata reference: 10812 fix/workaround: connect the alternate di and do pins externally and use the port mux to switch between pin configurations for master and slave functionality.
626 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 2 - when the sercom is in slave spi mode, the bufovf flag is not automatically cleared when ctrlb.rxen is set to zero. errata reference: 10563 fix/workaround: the bufovf flag must be manually cleared by software. 3 - the sercom spi bufovf status bit is not set until the next character is received after a buffer overflow, instead of directly after the overflow has occurred. furthermore the ctrla.ibon bit will always be zero and cannot be changed. errata reference: 10551 fix/workaround: none. 35.2.10 adc 1 - the automatic right shift of the result when accumulating/averaging adc samples does not work. er rata reference: 10530 fix/workaround: to accumulate or average more than 16 samples, one must add the number of automatic right shifts to avgctrl.adjres to perform the correct number of right shifts. for example, for averaging 128 samples, avgctrl.adjres must be written to 7 instead of 4, as the automatic right shift of 3 is not done. for oversampling to 16 bits resolution, avgctrl.adjres must be written to 4 instead of 0 as the automatic right shift of 4 is not done. the maximum number of right shifts that can be done using adjres is 7. this means that when averaging more than 128 samples, the result will be more than 12 bits, and the additional right shifts to get the result down to 12 bits must be done by firmware. 35.2.11 flash 1 - when cache read mode is set to deterministic (readmode=2), setting cachedis=1 does not lead to 0 wait states on flash access. errata reference: 10830 fix/workaround: when disabling the cache (ctrlb.cache dis=1), the user must also set readmode to 0 (ctrlb.readmode=0). 2 - when nvmctrl issues either erase or write commands and the nvmctrl cache is not in low_po wer mode, cpu hardfault exception may occur. errata reference: 10804 fix/workaround: either: - turn off cache before issuing flash commands by setting the nvmctrl ctrlb.cachedis bit to one.
627 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 - configure the cache in low_power mode by writing 0x1 into the nvmctrl ctrlb.readmode bits. 35.3 revision b 35.3.1 nvmctrl 1 - when the part is secured and ee prom emulation area configured to none, the crc32 is not executed on the en tire flash area but up to the on- chip flash size minus half a row. errata reference: 11988 fix/workaround: when using crc32 on a protected device with eeprom emulation area configured to none, compute the reference crc32 value to the full chip flash size minus half row. 35.3.2 vreg 1 - with default bit and register settings the device does not work as specified in standby mode if lo ad current exceeds 100a. errata reference: 11082 fix/workaround: set the forceldo bit in the vreg register. 35.3.3 device 1 - the values stored in the nvm soft ware calibration area for the dfll calibration are not valid. errata reference: 12843 fix/workaround: none. 2 - clock failure detection for externa l osc does not work in standby mode. errata reference: 12688 fix/workaround: before entering standby mode, move the cpu clock to an internal rc, disable external osc and disable the clock failure detector. upon cpu wakeup, restart external osc (if it does not start, the failure occurred during standby), enable the clock failure detector and move the cpu clock to the external osc. 3 - if apb clock is stopped and gclk clock is running, apb read access to read-synchronized registers will fr eeze the system. the cpu and the dap ahb-ap are stalled, as a consequen ce debug operation is impossible. errata reference: 10416 fix/workaround:
628 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 do not make read access to read-synchronized registers when apb clock is stopped and gclk is running. to recover from this situation, power cycle the device or reset the device using the resetn pin. 4 - the port output driver strength feature is not available. errata reference: 12684 fix/workaround: none 5 - maximum toggle frequency on all pi ns in worst case operating condition is 8mhz. this affects all operations on the pins, including serial communications. errata reference: 10335 fix/workaround: none. 6 - do not enable timers/counters, ac (analog comparator), gclk (generic clock controller), and sercom (i2c a nd spi) to control digital outputs in standby sleep mode. errata reference: 12786 fix/workaround: set the voltage regulator in normal mode before entering standby sleep mode. this is done by setting the runstdby bit in the vreg register. 7 - after a clock failure detection (i ntflag.cfd = 1), if intflag.cfd is cleared while the clock is still broken, the system is stuck. errata reference: 12687 fix/workaround: after a clock failure detection, do not clear intflag.cfd or perform a system reset. 8 - the temperature sensor is not accura te. no value is written into the temperature log row during production test. errata reference: 11731 fix/workaround: none 9 - the dfllval.coarse, dfllval.fine, dfllmul.cstep and dfllmul.fstep bit groups are not corr ectly located in the register map. dfllval.coarse is only 5 bits and located in dfllval[12..8]. dfllval.fine is only 8 bits and lo cated in dfllval[7:0]. dfllmul.cstep is only 5 bits and located in dfllmu l[28:24]. dfllmul.fstep is only 8 bits and located in df llmul[23:16] errata reference: 10988 fix/workaround: dfllval.coarse, dfllval.fine, dfllmul.cstep and dfllmul.fstep should not be used if code compatibility is required with future device revisions.
629 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 10 - if the external xosc32k is broken , neither the external pin rst nor the gclk software reset can reset the gclk generators using xosc32k as source clock. errata reference: 12164 fix/workaround: do a power cycle to reset the gclk generators after an external xosc32k failure. 35.3.4 pm 1 - in debug mode, if a watchdog r eset occurs, the debug session is lost. errata reference: 12196 fix/workaround: a new debug session must be restart after a watchdog reset. 2 - the systick timer does not generate a wake up signal to the power manager, and therefore cannot be used to wake up the cpu from sleep mode. errata reference: 11012 fix/workaround: none. 35.3.5 gclk 1 - when the gclk generator is enabled (genctrl.genen = 1), set as output (genctrl.oe = 1) and use a divi sion factor of one (gendiv.div = 1 or 0 and genctrl.divsel=0), the gclk_io might not be set to the configured genctrl.oov value af ter disabling the gclk generator (genctrl.genen=0). errata reference: 10716 fix/workaround: disable the oe request of the gclk generator (genctrl.oe = 0) before disabling the gclk generator (genctrl.genen = 0). 2 - the gclk generator clock is st uck when disabling the generator and changing the division factor from on e to a different value while the gclk generator is set as output. when the gclk generator is enabled (genctrl.genen=1), set as output (g enctrl.oe=1) and use a division factor of one (gendiv.div=1 or 0 an d genctrl.divsel=0), if the division factor is written to a value different of one or zero after disabling the gclk generator (genctrl.genen=0), the gclk generator will be stuck. errata reference: 10686 fix/workaround: disable the oe request of the gclk generator (genctrl.oe=0) before disabling the gclk generator (genctrl.genen=0).
630 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 3 - when a gclk is locked and the ge nerator used by the locked gclk is not gclk generator 1, issuing a gclk software reset will lock up the gclk with the syncbusy flag always set. errata reference: 10645 fix/workaround: do not issue a gclk swrst or map gclk generator 1 to ""locked"" gclks. 35.3.6 xosc32k 1 - the automatic amplitude control of the xosc32k does not work. errata reference: 10933 fix/workaround: use the xosc32k with automatic amplitude control disabled (xosc32k.aampen = 0) 35.3.7 dfll48m 1 - if the firmware writes to the dfll mul.mul register in the same cycle as the closed loop mode tries to update it, the fine calibration will first be reset to midpoint and then incremented/d ecremented by the closed loop mode. then the coarse calibration will be pe rformed with the updated fine value. if this happens before the dfll have got a lock, the new fine calibration value can be anything between 128-dfllm ul.fstep and 128+ dfllmul.fstep which could give smaller calibration rang e for the fine calibration. errata reference: 10634 fix/workaround: always wait until the dfll48m has locked before writing the dfllmul.mul register 2 - the dfll clock must be requested before being configured otherwise a write access to a dfll register can freez e the device. errata reference: 9905 fix/workaround: write a zero to the dfll ondemand bi t in the dfllctrl register before configuring the dfll module. 3 - changing the dfllval.fine calibration bits of the dfll48m digital frequency locked loop might result in a short output frequency overshoot. this might occur both in open loop mode while writing dfllval.fine by software and closed loop mode when the dfll automatically adjusts its output frequency. errata reference: 10537 fix/workaround: - when using dfll48m in open loop mode, be sure the dfll48m is not used by any module while dfllval.fine is written. - when using dfll48m in closed loop mode, be sure that dfllctrl.stable is written to 1. the dfll clock should not be used by any modules until the dfll locks are set.
631 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 if the application requires on-the-fly dfll calibrat ion (temperature/vcc drift compensation), the firmware should perform, either periodically or when the dfll48m frequency differ too much from target frequency (indicated by dfllval.diff), the following: o switch system clock/module clocks to different clock than dfll48m o re-initiate a dfll48m closed loop lock sequence by disabling and re-enabling the dfll48m o wait for fine lock (pclksr.dflllckf set to 1) o switch back system clock/module clocks to the dfll48m better accuracy is achieved using a high multiplier for the dfll48m, using a scaled down or slow clock as reference. a multiplier of 6 will have a theoretical worst case frequency deviation from the reference clock of +/- 8.33%. a multiplier of 500 will have a theoretical worst case frequency deviation from the reference clock of +/- 0.1%. 4 - if the dfll48m reaches the maximum or minimum coarse or fine calibration values during the locking sequence, an out of bounds interrupt will be generated. these interrupts will be generated even if the final calibration values at dfll48m lock are not at maximum or minimum, and might therefore be false out of bounds interrupts. errata reference: 10669 fix/workaround: check that the lockbits: dflllckc and dflllckf in the sysctrl interrupt flag status and clear register (intflag) are both set before enabling the dflloob interrupt. 35.3.8 evsys 1 - using synchronous or resynchronized paths, some channe ls (0,3,6,7) detect an overrun on every event even if no overrun condit ion is present. errata reference: 10895 fix/workaround: - ignore overrun detection bit for channels 0,3,6,7. - use channels 1,2,4,5 if overrun detection is required. 2 - changing the selected generator of a chan nel can trigger a spurious interrupt/event. errata reference: 10443 fix/workaround: to change the generator of a channel, first write with edgesel written to zero, then perform a second write with edgesel written to its target value. 35.3.9 sercom 1 - the sercom spi ctrla register bit 17 (dopo bit 1) will always be zero, and cannot be changed. therefore the sercom spi cannot be switched be tween master and slave mode on the same di and do pins. errata reference: 10812 fix/workaround: connect the alternate di and do pins externally and use the port mux to switch between pin configurations for master and slave functionality. 2 - when the sercom is in slave spi mode, th e bufovf flag is not automatically cleared when ctrlb.rxen is set to zero. errata reference: 10563
632 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 fix/workaround: the bufovf flag must be manually cleared by software. 3 - the sercom spi bufovf status bit is not set until the next character is received after a buffer overflow, instead of directly after the overflow has occu rred. furthermore the ctrla.ibon bit will always be zero and ca nnot be changed. errata reference: 10551 fix/workaround: none. 35.3.10 adc 1 - the automatic right shift of the result when accumulating/averaging adc samples does not work. errata reference: 10530 fix/workaround: to accumulate or average more than 16 samples, one must add the number of automatic right shifts to avgctrl.adjres to perform the corr ect number of right shifts. for example, for averaging 128 samples, avgctrl.adjres must be written to 7 instead of 4, as the automatic right shift of 3 is not done. for oversampling to 16 bits resolution, avgctrl.adjres must be written to 4 instead of 0 as the automatic right shift of 4 is not done. the maximum number of right shifts that can be done using adjres is 7. this means that when averaging more than 128 samples, the result will be more than 12 bits, and the additional right shifts to get the result down to 12 bits must be done by firmware. 35.3.11 ptc 1 - some gain settings for the ptc in self-cap acitance mode do not work. the two lowest gain settings are not selectable and an attempt by the qtouch library to set enable of these may result in a higher sensitivity than optima l for the sensor. the ptc will not detect all touches. this errata does not affect mutual-capacitance mode which operates as specified. errata reference: 10684 fix/workaround: use sam d20 revision c or later for self-capacitance touch sensing. 35.3.12 flash 1 - when cache read mode is set to dete rministic (readmode=2), setting cachedis=1 does not lead to 0 wait states on flash access. errata reference: 10830 fix/workaround: when disabling the cache (ctrlb.cachedis=1), the user must also set readmode to 0 (ctrlb.readmode=0). 2 - when nvmctrl issues either erase or wr ite commands and the nvmctrl cache is not in low_power mode, cpu hardfault excepti on may occur. errata reference: 10804 fix/workaround: either:
633 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 - turn off cache before issuing flash commands by setting the nvmctrl ctrlb.cachedis bit to one. - configure the cache in low_power mode by writing 0x1 into the nvmctrl ctrlb.readmode bits. 35.4 revision a not sampled
634 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36. datasheet revision history please note that the referring page numbers in this section are referred to this document. the referring revision in this section are referring to the document revision. 36.1 rev. k ? 05/2014 description z updated partially the atmel sam d20 ?description? on page 1 block diagram z vrefp on dac renamed vrefa memories z updated table 9-3 z changed the wdt window default value, window_1 to 0x5 dsu - device service unit z updated ?dsu chip identification method:? on page 43 z ?family? renamed ?product family? and subfamily became ?product series? z updated the protection state of the device in ? starting crc32 calculation? on page 44 sysctrl - system controller z updated ?8mhz internal oscillator (osc8m) operation? on page 134 z updated the description of wr iting to frange and calib z updated table 16-1 z dfll renamed dfll48m z added note on how to enter standby mode in: z ?external multipurpose crystal oscill ator (xosc) operation? on page 132 z ?32khz external crystal oscillator (xosc32k) operation? on page 132 z added vreg register z added vreg in ?register summary? on page 140 z updated the description of bit 6 ? runstdby and bit 13 ? forceldo z updated the description of ?interrupts? on page 138 z updated osc8m z bits 11:0 - calib has two calibration fields calib[11-6] and calib[5:0] rtc - real-time counter z updated ?analog connections? on page 197 z tosc1 and tosc2 renamed respectively xin32 and xout32 port z updated ?principle of operation? on page 283 z the reference for pin configuration registers changed to pincfgy sercom spi z updated ctrlb z bit 17 - rxen is r/w tc - timer/counter z updated table 27-6 z updated ctrlc z bits 1:0 - invenx: waveform output x invert enable ac - analog comparators z added bit 7 - lpmux in ctrla and updated ?register summary? on page 525 dac - digital -to- analog converter z added a new dac figure 30-1 with vrefp replaced by vrefa z updated ?signal description? on page 542 z vrefp renamed vrefa
635 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 electrical characteristics z updated table 32-1 z updated i vdd and i gnd max values z added a detailed table note for i vdd and i gnd z added table 32-2 z updated table 32-3 z removed table note (1) related to the operating conditions z updated the table 32-7 z updated values in active and idle0/1/2 modes z updated the max values @ 85 c in standby modes z max values updated to 100a both for rtc stopped and rtc running z updated ?i/o pin characteristics? on page 570 z updated title of table 32-9 to ?revd and later normal i/o pins characteristics? z updated i ol and i oh values in table 32-9 z updated title in table 32-9 z updated i ol and i oh in table 32-11 z table note (1) on c out removed from table 32-13 z updated the ?analog characteristics? on page 573 z updated max value of v pot- in table 32-14 . new max value is 1.32v z updated table note 3 in table 32-18 z updated table note 2 in table 32-19 z updated r sample in table 32-17 z added conversion rate for max 1000ksps in the table 32-23 z updated table 32-24 z added table note ?all values measured using a conversion rate of 350ksps? z updated ?software-based refinement of the actual temperature? on page 581 z added the address of the temperature log row z updated table 32-37 z removed the tlcoarse parameter as it is already set from calibration z updated i dfll and t startu typical values z updated ?crystal oscillator characteristics? on page 586 : z updated the max values of esr z updated the typical values of c xin and c xout z updated table 32-36 : z updated the table note z updated the max value of esr to 141 k , the typical values of c xin32 and c xout32 to respectively 3.1 and 3.3pf z updated table 32-43 z added table note (3) to t r and t of errata z added errata ?revision d? on page 619 z updated errata ?revision c? on page 621 z updated errata ?revision b? on page 627
636 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36.2 rev. j ? 12/2013 36.3 rev. i ? 12/2013 nvmctrl - non- volatile memory controller cleaned up the ctrlb register. general removed ?preliminary? description z updated partially the atmel sam d20 ?description? on page 1 features z power consumption has been updated to ?down to 8a running the peripheral touch controller? configuration summary updated the ?configuration summary? on page 3 ordering information updated ?ordering information? on page 4 z added at prefix at the start of the ordering codes block diagram updated the ?block diagram? on page 7 z added the description of the connection between port and arm cortex-m0+ cpu: arm single cycle iobus z renamed generic clock to generic clock controller i/o multiplexing and considerations updated the ?i/o multiplexing and considerations? on page 11 z renamed all gclk/io[x] to gclk_io[x] in the table 5-1 z updated the description of the ?serial wire debug interface pinout? on page 13 z added swdio to pa31 column g in the table 5-1 and added a footnote product mapping changed peripheral to ahb-apb signal description updated the ?signal descriptions list? on page 14 z removed gclk from the heading ?generic clock generator? z renamed io[7:0] to gclk_io[7:0] memories z added ?serial number? on page 23 z software calibration row changed to software calibration area z added figure 9-1 z updated the table 9-4 z added the bod33 and bod12 default settings z added dfll48m coarse cal and dfll48m fine cal z added table notes on rev c (bit 40 and bit 41) to the table 9-3 device service unit z updated table 12-7 z redefined did register. family changed from 4 bits to 5 bits and series from 8 bits to 6 bits z updated did register z updated family and series bit registers z updated table 12-8 . added atsamd20e18a device at 0xa.
637 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 clock system updated ?clock system? on page 73 z updated the clock names in the figure 13-1 z updated the description of generic clock generators and generic clocks in the ?clock distribution? on page 73 z updated figure 13-2 z synchronous clock controller renamed to main clock controller z updated the description of ?read-synchronization? on page 76 z changed the title ?enable write-synchronization? to ?write-synchronization of ctrl.enable? on page 76 z updated ?clocks after reset? on page 78 z renamed gclkmain to gclk_main generic clock controller z updated the ?overview? on page 79 and renamed gclk_periph to gclk_peripheral throughout the datasheet z updated ?features? on page 79 z updated ?block diagram? on page 79 z updated figure 14-1 z updated figure 14-2 and added note z updated links in ?power management? on page 80 and in ?clocks? on page 80 z updated ?functional description? on page 81 z added links in ?initialization? on page 81 for gendiv, genctrl and clkctrl z updated the figure 14-3 z renamed ?external clock? to ?generic clock output on i/o pins? on page 83 and updated the description z updated the figure 14-4 and renamed it ?generic clock multiplexer? z updated the description of ?disabling a generic clock? on page 84 z updated the figure 14-5 . gclk becomes generic clock z updated links in ?run in standby mode? on page 85 and in ?synchronization? on page 85 z added a table note on the reset in genctrl z added a third column ?generator clock source? to table 14-7 z replaced the text ? if the generator is not used by the rtc ? by the ? if the generator is not used by the rtc and not a source of a 'locked' generic clock ? in the table 14-8 and in table 14-12 z updated the table 14-12
638 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 power manager z updated ?overview? on page 101 z ?power save modes? is changed to ?sleep modes? z a new line is added: ?this is because during standby sleep mode the internal voltage regulator will be in low power mode? z updated ?features? on page 101 z clock control: ?generates? is changed to ?controls? z updated ?clocks? on page 103 z ?this clock? is changed to ?the clock source for gclk_main? z updated ?interrupts? on page 103 z added: ?refer to ?nested vector interrupt controller? on page 25 for details? z updated ?register access protection? on page 103 z added: ?refer to intflag for details? z added: ?refer to rcause for details? z updated ?synchronous clocks? on page 104 z added: ?see table 15-4 ? z updated ?reset controller? on page 104 z ?resets? corrected to ?reset? z updated ?sleep mode controller? on page 104 z added: ?see table 15-4 ? z updated ?initialization? on page 104 z added: ?- refer to rcause for details? z updated ?selecting the synchronous clock division ratio? on page 104 z added: ?(apbxsel.apbxdiv)? z updated figure 15-2 z updated ?clock ready flag? on page 105 z ?cksel? is changed to ?cpusel? z updated ?peripheral clock masking? on page 105 z added: ?- refer to apbamask for details? z the first sentence below the figure has been changed to: ?when the apb clock for a module is not provided its registers cannot be read or written.? z updated ?clock failure detector? on page 106 z ?cfden.ctrl? has been changed to ?ctrl.cfden? z added: ?refer to ctrl for detailed information.? z ?divided? has been changed to ?undivided? z ?is generated, if enabled? has been changed to "is set and the corresponding interrupt request will be generated if enabled" z ?gclkmain? has been changed to ?gclk_main? z added: note 3 z updated table 15-2 z ?gclk? has been changed to ?generic clock? z updated figure 15-3 z updated table 15-3 z two notes (?synchronous? and ?asynchronous?) are added below the table z updated ?sleep mode controller? on page 108 z updated the text in standby mode
639 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 power manager (cont.) z updated table 15-4 z replaced the table with an accurate one z updated ?idle mode? on page 109 z second bullet: ?any non-masked interrupt? changed to ?the occurrence of any interrupt that is not masked in the nvic controller? z updated ?standby mode? on page 109 z ?gclk? is changed to ?generic clock? z added: ?sleepwalking? on page 110 z updated ?bit 4 ? bkupclk: backup clock select? on page 114 z ?gclkmain? is changed to ?gclk_main? sysctrl - system control z updated ?overview? on page 128 z ?xosc, xosc32k, osc32k, osculp32k , osc8m, dfll48m, bod33, bod12, vreg and vref? is changed to ?clock sources, brown out detectors, on-chip voltage regulator and voltage reference of the device." z added: ?- refer to pclksr ? z added: ?( intenset )? z added: ?( intenclr )? z added: ?( intflag )? z updated ?principle of operation? on page 131 z added two tables for the behavior of oscillators and sleep modes z updated ?register access protection? on page 130 z added: ?- refer to intflag ? z updated ?analog connections? on page 130 z changed ?load. refer? to ?load, refer? z updated ?external multipurpose crystal oscillator (xosc) operation? on page 132 z changed ?the only? to ?only the? z ?the xtal enable bit (xosc.xtalen) must written to one? is changed to ?a one must be written to the xtal enable bit (xosc.xtalen)." z updated ?32khz external crystal oscillator (xosc32k) operation? on page 132 z ?power-on, reset? is changed to ?power-on reset (por)? z added: "xosc32k can provide two clock outputs when connected to a crystal.? z updated the description z updated the description of ?8mhz internal oscillator (osc8m) operation? on page 134 z updated ?32khz internal oscillator (osc32k) operation? on page 133 z changed ?calib? to ?osc32k.calib? z changed ?non-volatile memory? to ?nvm software calibration row? z added: ?(refer to ?nvm software calibration area mapping? on page 23 )? z updated ?32khz ultra low power internal oscillator (osculp32k) operation? on page 134 z added: ?- osculp32k ? z updated ?closed-loop operation? on page 135 z list #3: changed ?device? to ?dfll? z below ?drift compensation?: ?set? has been replaced by ?triggered? z the text ?shown in figure 16-1 ? has been removed
640 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 sysctrl - system control (cont.) z updated ?additional features? on page 136 z the text ?when disabling the dfll48m? below ?wake from sleep modes? has been replaced by the text ?when the dfll is turned off? z updated ?3.3v brown-out dete ctor (bod33)? on page 137 z ?brown-out detector? is replaced by ?bod33? z updated ?32khz internal oscillator (osc32k) control? on page 159 z the reference for bits 22:16 - calib[6:0] has been corrected z updated table 16-3 z both notes for this table has been updated/changed z new ?note 3? is added z updated table 16-5 z both notes for this table has been updated/changed z new ?note 3? is added z updated table 16-6 z new column for ?number of osc32k clock cycles? is added z the values in the column for the ?old? ?number of osc32k clock cycles? has been corrected z both notes for this table has been updated/changed z new ?note 3? is added z updated ?dfll48m control? on page 166 z for ?property? the following has been added: ?, write-synchronized? z removed runstdby and updated the dfllctrl z updated ?dfll48m value? on page 168 z for ?property? the following has been added: ?, read-synchronized? z updated ?register access protection? on page 179 z in the bullet point the following is added: ?- refer to intflag ? z updated ?principle of operation? on page 179 z added: ?- refer to ctrl ? and ?- refer to intenclr ? z updated ?initialization? on page 179 z added: ?- refer to ctrl ?, ?- refer to config ?, and ?- refer to ewctrl ? z updated ?normal mode? on page 180 z added: ?- refer to clear ? z updated the description of the bit 4 dfll ready in pclksr register and updated bit 11 bod33 synchronization ready z updated the default reset value in osc8m register and fixed the range bitfield wdt z updated the description of the bit 2 (ctrl.wen) in ctrl z removed ?asynchronous watchdog clock characterization? spi z updated the description of the ?spi transfer modes? on page 365 rtc - real-time counter z updated ?register access protection? on page 197 z added: ?- refer to intflag ?, ?- refer to readreq ?, ?- refer to status ?, and ?- refer to dbgctrl ? z updated ?initialization? on page 198 z added: ?- refer to evctrl ?
641 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 eic - external interrupt controller z updated the description of ?events? on page 240 z added text ?eic generates events as pulses?. z updated ?sleep mode operation? on page 244 z added text ?using wakeupen[x]=1 with intenset=0 is not recommended? z updated ?register access protection? on page 241 z added: ?- refer to intflag ? and ?- refer to nmiflag ? z updated ?additional features? on page 243 z added: ?- refer to nmictrl ? nvmctrl - non- volatile memory controller z updated ?power management? on page 259 z added: ?- refer to ctrlb ? z added ?basic operations? on page 260 z updated ?interrupts? on page 259 z added a reference link to ?nested vector interrupt controller? on page 25 z updated the description of ?nvm read? on page 262 z updated ?register access protection? on page 259 z added: ?- refer to intflag ? and ?- refer to status ? z updated the description of manw bit in ctrlb register z updated the description of error and ready bits in intenclr register port z updated ?cpu local bus? on page 282 z added: ?- refer to dir ?, ?- refer to out ?, ?- refer to in , and ?- refer to ctrl ? z updated ?principle of operation? on page 283 z added: ?- refer to dir ?, ?- refer to out ?, ?- refer to pincfg0 ?, ?- refer to in ?, and ?- refer to pmux0 ? tc z updated table 27-6 . switched ?clear? and ?set? for cco value (mpwm). adc z updated the description of ?sleep mode operation? on page 484 z added ?while the cpu is sleeping, adc conversion can only be triggered by vents? z software calibration row changed to software calibration area ac z updated the description of ?sleep mode operation? on page 522 z added ?while the cpu is sleeping, single-s hot comparisons are only triggerable by events?
642 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 electrical characteristics z updated ?disclaimer? on page 563 . removed the preliminary disclaimer z updated table 32-1 z updated i vdd and i gnd max values z added t storage z updated table 32-3 z added v ddio - v ddana z updated the table 32-7 z added min and max values z added consumption data z updated i ol and i oh in table 32-9 z updated v hys min value in table 32-11 z updated i ol and i oh in table 32-9 z duplicated all tables in ?i/o pin characteristics? on page 570 to differentiate rev d ( table 32-9 ) from rev c ( table 32-10 ) z updated the table 32-12 z renamed table 32-12 to voltage regulator electrical characteristics z added condition to v ddcore characteristics z updated table 32-15 z added a table note to specify bod33.level default production settings z updated table 32-16 z added current consumption data (i bod33 ) z added ?? on page 574 z removed the min value of i dd from table 32-17 z updated the bandgap gain error min and max values in table 32-18 z updated i dd values and conditions in table 32-22 z removed the table note from table 32-24 z updated the accuracy unit in table 32-26 z removed t ffp from table 32-32 z updated the ?temperature sensor characteristics? on page 581 z updated the ?crystal oscillator characteristics? on page 586 z added new characterization data z removed f cpxin min value from table 32-33 z changed the title to ?digital frequency locked loop (dfll48m) characteristics? on page 588 and added table note to table 32-37 z updated table 32-36 z updated i xosc32k z added a table note for ?agc on?: data are not yet available for rev d z added current consumption data (i osc32k ) in the table 32-38 z updated i osc8m in table 32-40 package z added notes to ?64-pin qfn? on page 602 , ?48-pin qfn? on page 604 and to ?32-pin qfn? on page 606 z updated table 33-14 and table 33-17 z device and package maximum weight is 100mg for tqfp32 and 90mg for qfn32
643 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36.4 rev. h ? 10/2013 configuration summary added 256kb flash and 32kb sram to the sam d20e ordering information added samd20e18 to the ?sam d20e? on page 4 sysctrl added note to intflag nvmctrl updated links to the table 20-3 sercom usart updated table 24-6 . sercom pad[x] renamed pad[x] adc z updated the ?features? on page 474 . up to 350,000 samples per second (350ksps) z updated the broken link for inputctrl z removed ?additional features? schematic checklist z added information about jtagice3 compatible swd connector z updated connector names to match the names used by arm z added information about general debugging and programming to ?programming and debug ports? on page 615 electrical characteristics z updated table 32-3 . added table note related to bod33 z updated ?i/o pin characteristics? on page 570 . all v ddana ranges are 1.62v - 2.7v and 2.7v - 3.63v z updated ?digital frequency locked loop (dfll48m) characteristics? on page 588 z updated table 32-5 z replaced the maximum value that was based on simulation by the actual measurement value z removed the unused columns z updated the typical values of while(1) at 1.8v in the table 32-7 z updated the table 32-13 z used measurement values z removed the min and max values z added values for c in and c out z added a table note z updated the table 32-17 z added min and max values for i dd z updated typical values z updated the table 32-19 z added min and max values z added characteristics for enob, sfdr, sinad and thd
644 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36.5 rev. g ? 10/2013 electrical characteristics z updated the table 32-22 . added min and max values for i dd z replaced v dd by v ddana in the table 32-23 z updated the table 32-25 z added min and max values z added characterization data for v scale z updated the table 32-18 , table 32-24 and table 32-27 z added min and max values z updated table 32-30 and table 32-31 . added table note related to the cycling endurance z added output frequency characteristics data to the table 32-38 , table 32-39 and table 32- 40 z updated all tables in ?i/o pin characteristics? on page 570 . added new characterization data z added v ddcore characteristics to the table 32-12 z updated the table table 32-14 , table 32-26 , table 32-15 and table 32-16 . added new characterization data z updated all tables in ?oscillators characteristics? on page 586 . added new characterization data errata added errata ?revision c? on page 621 features added the power consumption gclk updated table 14-9 z generic clock generator 0 has 8 division factor bits - div[7:0] nvmctrl updated the table 20-3 electrical characteristics updated the ?electrical characteristics? on page 563 z updated the table 32-7 . added values of cpu running a ?while(1)? algorithm z moved the ptc typical figures from the typical characteristics into the ?electrical characteristics? on page 563 z updated the ?analog characteristics? on page 573 cout max value in the table 32-13 is 1000nf instead of 200nf z updated the ?nvm characteristics? on page 585 : z added note about the max number of consecut ive write in a row bef ore an erase becomes mandatory z removed all ?based on simulation? notes z updated the table 32-29 , table 32-30 and table 32-31
645 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36.6 rev. f ? 10/2013 36.7 rev. e ? 09/2013 36.8 rev. d ? 08/2013 i/o multiplexing and considerations updated the table 5-1 z pa16 and pa17 are i 2 c pins in sercom1 memories updated the table 9-4 z bit positions [14:3] and [26:15] are ?reserved? adc updated the ?calibration? on page 477 according to the update done in the ?nvm software calibration area mapping? on page 23 ptc the ?ptc - peripheral touch controller? on page 558 was completely updated typical characteristics added the ptc in the typical characteristics errata added ptc in errata ?revision b? on page 627 ordering information updated the figure of the ?ordering information? on page 4 z removed ?h = -40 - 85c nipdau plating? from the package grade z renamed ?product variant? to ?device variant? in the figure of the ?ordering information? on page 4 dsu updated the did register did z renamed subfamily [7:0] bits to series [7:0] bits z the whole description of the did bit registers updated z added device (all products in the sam d20 family) column in device selection table (devsel) sysctrl added enable bits for the bods and oscillators electrical characteristics updated ?supply characteristics? on page 565 z moved the max values to the min columns into the table 32-5 z updated the max values by correct data in the table 32-5 updated the ?i/o pin characteristics? on page 570 z fixed typos in table 32-9 , table 32-10 and table 32-11 : ?vdd? was missing in some cells of the tables. description updated the whole atmel sam d20 ?description? on page 1 general fixed different typos throughout the datasheet and applied correctly the template block diagram updated the ?block diagram? on page 7 z added 2kb ram and 16kb flash
646 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36.9 rev. c ? 07/2013 dsu updated the figure 12-1 z removed hram from the block diagram clock system updated ?clock system? on page 73 z the description of the basic read request has been updated z updated the figure 13-3 sysctrl z updated the writing of the interrupt sources in ?interrupts? on page 138 z added the reference to intflag nvmctrl updated the figure 20-2 z removed the blue mark from the figure port z ?cpu local bus? on page 282 : iobus address 0x60000000 added z removed rwm from the description evsys channel register ( channel ): z bits 25:24: channel:path description updated. schematic checklist updated the ?schematic checklist? on page 608 z updated ?introduction? on page 608 z replaced all tdb by their respective values z wrote correctly the ohm symbol in ?external reset circuit? on page 611 electrical characteristics z updated ?electrical characteristics? on page 563 z removed the colors from ?electrical characteristics? on page 563 z added footnote in the figure 32-17 . f adc = 6 * clk adc table of contents z applied correctly the template for the toc description updated the front page: z removed the ?embedded flash? from the title and from the description on the page 1 z replaced ?speeds? by ?frequencies? on the page 1 z added a sub-bullet on ptc in feature list (256-channel capacitive touch and proximity sensing) on the page 2 z replaced io lines by io pins on the page 2 configuration summary updated the table z the rtc z i/o lines changed to i/o pins z changed 32.768khz high-accuracy oscillator to 32.768khz oscillator z changed 32.768khz ultra-low power internal oscillator to 32khz ulp oscillator z changed 8mhz internal oscillator to 8mhz high-accuracy internal oscillator z updated sw debug interface z updated the wdt ordering information z replaced ?base line? by ?general purpose? z centered the tables except the ordering code table. about the document z renamed the chapter to appendix a and appendix b z moved the two appendixes at the end of the datasheet z changed the tag of the tables to the tag of appendix tables
647 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36.10 rev. b ? 07/2013 pinout z updated the description of ?multiplexing signals? z replaced ?port controller? by ?port? z set the table 5-1 as a continuing table z updated the table notes of the table 5-1 z replaced i/o lines by i/o pins on the page 17 signal description z removed the column ?comment? from the table power supply z removed ?nominal? from power supplies z updated the description of vector regulator z added link to the ?schematic checklist? clock system added the link in the description of ?write-synchronization? on page 75 power manager updated the table 15-4 : z the column ?clock sources? has been updated with new commands z the table note 2 replaced by a reference to ?on-demand, clock requests? on page 77 adc interrupt flag status and clear register ( intflag ): z bit 2: intflag.winmon description updated z bit 1: intflag.overrun description updated z bit 0: intflag.resrdy description updated dac z ?register summary? on page 547 : data and databuf bit fields updated. z data register: bit fields and description updated. z databuf register: bit fields and description updated. electrical chara added ?electrical characteristics? on page 563 package information corrected the 64 pins qfn drawing block diagram ?block diagram? on page 7 : added output from analog comparator block signal description ?signal descriptions list? on page 14 : signal description table cleaned up memories ?nvm software calibration area mapping? on page 23 : added osc32k calibration to table 9-4 dsu die identification register ( did ): z bit 15:12: added die[3:0] bit group z bit 11:8: added revision[3:0] bit group evsys ?features? on page 306 : number of event generat ors updated from 59 to 58 sercom spi control a register ( ctrla ): z bit 16: ctrla.dopo updated to bit17:16: ctrla.dopo[1:0] z bit 17:16 - dopo[1:0] description updated status register ( status ): z bit 2 - status.bufovf description updated
648 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 36.11 rev. a ? 06/2013 adc ?accumulation? on page 481 : section added ?averaging? on page 481 : section updated ?oversampling and decimation? on page 482 : section updated ac ?starting a comparison? on page 516 : heading updated from basic operation. ?synchronization? on page 523 : updated with list of write-synchronized bits and registers register property updated to ?write-synchronized?: z ctrla , comparator control n sysctrl z removed vddmon and enable bits from registers. z updated start-up time tables for xosc32k and osc32k: z xosc register: table 16-3 z xosc32k register: table 16-5 z osc32k register: table 16-6 errata rev. b ?revision b? on page 627 updates: z ?device? on page 627 : two erratas added (10988 and 10537) z ?pm? on page 629 : two erratas added (10858 and 11012) z ?xosc32k? on page 630 : one errata added (10933) z ?dfll48m? on page 630 : two erratas added (10634, 10537), one errata updated (10669) z ?evsys? on page 631 : one errata added (10895) z ?sercom? on page 631 : two erratas added (10812 and 10563), one errata removed (10563) z ?adc? on page 632 : one errata updated (10530) z ?flash? on page 632 : one errata updated (10804) errata rev. a status changed to ?not sampled? 1. initial revision
649 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 appendix a. conventions a.1 numerical notation a.2 memory size and type a.3 frequency and time table a-1. numerical notation symbol description 165 decimal number 0b0101 binary number (example 0b0101 = 5 decimal) 0101 binary numbers are given without suffix if unambiguous 0x3b24 hexadecimal number x represents an unknown or don't care value z represents a high-impedance (floating) state for either a signal or a bus table a-2. memory size and bit rate symbol description kb (kbyte) kilobyte (2 10 = 1024) mb (mbyte) megabyte (2 20 = 1024*1024) gb (gbyte) gigabyte (2 30 = 1024*1024*1024) b bit (binary 0 or 1) b byte (8 bits) 1kbit/s 1,000 bit/s rate (not 1,024 bit/s) 1mbit/s 1,000,000 bit/s rate 1gbit/s 1,000,000,000 bit/s rate word 32 bit half-word 16 bit table a-3. frequency and time symbol description khz 1khz = 10 3 hz = 1,000hz mhz 10 6 = 1,000,000hz ghz 10 9 = 1,000,000,000hz s second
650 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 a.4 registers and bits ms millisecond s microsecond ns nanosecond table a-3. frequency and time (continued) symbol description table a-4. register and bit mnemonics symbol description r/w read/write accessible register bit. the us er can read from and write to this bit. r read-only accessible register bit. the user can only read this bit. writes will be ignored. w write-only accessible register bit. the user can only write this bit. reading this bit will return an undefined value. bit bit names are shown in uppercase. (example enable) field[n:m] a set of bits from bit n down to m. (examp le: pina[3:0] = {pina3, pina2, pina1, pina0} reserved reserved bits are unused and reserved for future use. for compatibility with future devices, always write reserved bits to zero when the register is wr itten. reserved bits will always return zero when read. peripheral i if several instances of a peripheral exist, the peripher al name is followed by a number to indicate the number of the instance in the range 0-n. peripheral0 denotes one specific instance. reset value of a register after a power reset. this is also the value of registers in a peripheral after performing a software reset of the peripheral, except for the debug control registers. set/clr registers with set/clr suffix allows the user to cl ear and set bits in a register without doing a read- modify-write operation. these registers always come in pairs. writing a one to a bit in the clr register will clear the corresponding bit in both registers, while writing a one to a bit in the set register will set the corresponding bi t in both registers. both registers will return the same value when read. if both registers ar e written simultaneously, the write to th e clr register will take precedence.
651 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 appendix b. acronyms and abbreviations table b-1 contains acronyms and abbreviations used in this document. table b-1. acronyms and abbreviations abbreviation description ac analog comparator adc analog-to-digital converter addr address ahb amba advanced high-performance bus amba ? advance microcontroller bus architecture apb amba advanced peripheral bus aref analog reference voltage blb boot lock bit bod brown-out detector cal calibration cc compare/capture clk clock crc cyclic redundancy check ctrl control dac digital-to-analog converter dap debug access port dfll digital frequency locked loop dsu device service unit eeprom electrically erasable programmable read-only memory eic external interrupt controller evsys event system gclk generic clock controller gnd ground gpio general purpos e input/output i 2 c inter-integrated circuit if interrupt flag int interrupt mbist memory built-in self-test mem-ap memory access port nmi non-maskable interrupt
652 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 nvic nested vector interrupt controller nvm non-volatile memory nvmctrl non-volatile memory controller osc oscillator pac peripheral access controller pc program counter per period pm power manager por power-on reset ptc peripheral touch controller pwm pulse width modulation ram random-access memory ref reference rtc real-time counter rx receiver/receive sercom serial communication interface smbus ? system management bus sp stack pointer spi serial peripheral interface sram static random-access memory sysctrl system controller swd serial wire debug tc timer/counter tx transmitter/transmit ulp ultra-low power usart universal synchronous and asynchronous serial receiver and transmitter v dd common voltage to be applied to vddio, vddin and vddana v ddin digital supply voltage v ddio digital supply voltage v ddana analog supply voltage vref voltage reference wdt watchdog timer xosc crystal oscillator table b-1. acronyms and abbreviations (continued) abbreviation description
653 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014
654 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 table of contents description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1. configuration summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2. ordering information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1 sam d20e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 sam d20g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3 sam d20j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3. block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4. pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.1 sam d20j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.2 sam d20g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.3 sam d20e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 5. i/o multiplexing and considerations . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.1 multiplexed signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.2 other functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6. signal descriptions list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7. power supply and start-up considerations . . . . . . . . . . . . . . . . . . . 16 7.1 power domain overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.2 power supply considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.3 power-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 7.4 power-on reset and brown-out detector. . . . . . . . . . . . . . . . . . . . . . . . . . . 18 8. product mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 9. memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 9.1 embedded memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 9.2 physical memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 9.3 non-volatile memory (nvm) user row mapping. . . . . . . . . . . . . . . . . . . . . . 22 9.4 nvm software calibration area mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 9.5 serial number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 10. processor and architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 10.1 cortex-m0+ processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 10.2 nested vector interrupt controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 10.3 high-speed bus matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 10.4 ahb-apb bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 10.5 pac ? peripheral access controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 10.6 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 11. peripherals configuration overview . . . . . . . . . . . . . . . . . . . . . . . . . 35 12. dsu ? device service unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 12.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 12.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
655 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 12.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 12.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 12.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 12.6 debug operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 12.7 chip-erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 12.8 programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 12.9 intellectual property protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 12.10 device identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 12.11 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 12.12 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 12.13 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 13. clock system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 13.1 clock distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 13.2 synchronous and asynchronous clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 13.3 register synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 13.4 enabling a peripheral. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 13.5 on-demand, clock requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 13.6 power consumption vs speed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 13.7 clocks after reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 14. gclk ? generic clock controller . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 14.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 14.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 14.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 14.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 14.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 14.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 14.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 14.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 15. pm ? power manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 15.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 15.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 15.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 15.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 15.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 15.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 15.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 15.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 16. sysctrl ? system controller . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 16.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 16.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 16.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 16.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 16.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 16.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 16.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 16.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
656 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 17. wdt ? watchdog timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 17.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 17.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 17.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 17.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 18. rtc ? real-time counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 18.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 18.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 18.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 18.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 18.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 18.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 18.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 18.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 19. eic ? external interrupt controller . . . . . . . . . . . . . . . . . . . . . . . . . 239 19.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 19.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 19.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 19.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 19.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 19.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 19.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 19.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 20. nvmctrl ? non-volatile memory controller . . . . . . . . . . . . . . . . 258 20.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 20.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 20.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 20.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 20.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 20.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 20.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 20.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 21. port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 21.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 21.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 21.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 21.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 21.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 21.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 21.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 21.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 22. evsys ? event system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 22.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
657 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 22.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 22.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 22.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 22.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 22.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 22.7 register summary 313 22.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 23. sercom ? serial communication interface . . . . . . . . . . . . . . . . . 329 23.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 23.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 23.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 23.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 23.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 23.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 24. sercom usart ? sercom universal sync hronous and asynchronous receiver and transmitter 337 24.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 24.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 24.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 24.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 24.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 24.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 24.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 24.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 25. sercom spi ? sercom serial peripheral interface . . . . . . . . . . 362 25.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 25.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 25.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 25.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 25.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 25.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 25.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 25.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 26. sercom i2c ? sercom inter-integrated circuit . . . . . . . . . . . . . 387 26.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 26.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 26.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 26.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 26.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 26.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 26.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401 26.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 27. tc ? timer/counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 27.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 27.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 27.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
658 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 27.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 27.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 27.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437 27.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 27.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450 28. adc ? analog-to-digital converter . . . . . . . . . . . . . . . . . . . . . . . . 474 28.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 28.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 28.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 28.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 28.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476 28.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477 28.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 28.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488 29. ac ? analog comparators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 29.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 29.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 29.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514 29.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514 29.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514 29.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516 29.7 additional features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 29.8 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 29.9 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526 30. dac ? digital-to-analog converter . . . . . . . . . . . . . . . . . . . . . . . . 542 30.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542 30.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542 30.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542 30.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542 30.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543 30.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544 30.7 register summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547 30.8 register description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 31. ptc - peripheral touch controller . . . . . . . . . . . . . . . . . . . . . . . . . 558 31.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558 31.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558 31.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 31.4 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560 31.5 product dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560 31.6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562 32. electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 32.1 disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 32.2 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 32.3 general operating ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 32.4 supply characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565 32.5 maximum clock frequencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565 32.6 power consumption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
659 atmel | smart sam d20 [datasheet] atmel-42129k?sam-d20_datasheet?06/2014 32.7 i/o pin characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570 32.8 analog characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573 32.9 nvm characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585 32.10 oscillators characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 32.11 ptc typical characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 32.12 timing characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595 33. packaging information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 33.1 thermal considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 33.2 package drawings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601 33.3 soldering profile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607 34. schematic checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608 34.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608 34.2 power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608 34.3 external analog reference connections . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 34.4 external reset circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 34.5 unused or unconnected pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 34.6 clocks and crystal oscillators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612 34.7 programming and debug ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615 35. errata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 35.1 revision d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 35.2 revision c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621 35.3 revision b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627 35.4 revision a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 36. datasheet revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634 36.1 rev. k ? 05/2014 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634 36.2 rev. j ? 12/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 36.3 rev. i ? 12/2013. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 36.4 rev. h ? 10/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643 36.5 rev. g ? 10/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644 36.6 rev. f ? 10/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645 36.7 rev. e ? 09/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645 36.8 rev. d ? 08/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645 36.9 rev. c ? 07/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646 36.10 rev. b ? 07/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647 36.11 rev. a ? 06/2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648 appendix a. conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649 a.1 numerical notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649 a.2 memory size and type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649 a.3 frequency and time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649 a.4 registers and bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650 appendix b. acronyms and abbreviations. . . . . . . . . . . . . . . . . . . . . . . 651 table of contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
x x x x x x arm connected logo atmel corporation 1600 technology drive, san jose, ca 95110 usa t: (+1)(408) 441.0311 f: (+1)(408) 436.4200 | www.atmel.com ? 2014 atmel corporation. / rev.: atmel-42129k-sam-d20_datasheet_06/2014. atmel ? , atmel logo and combinations ther eof, enabling unlimited possibilities ? , qtouch ? , and others are registered trademarks or trademarks of atmel corporation in u.s. and other countries. arm ? , cortex ? and others are registered trademarks or trademarks of arm ltd. arm ? , arm connected ? logo, and others are the registered trademarks or trademarks of arm ltd. other terms and product names may be trademarks of others. disclaimer: the information in this document is provided in connection with atmel products . no license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of atmel products. except as set forth in the atmel terms and condit ions of sales located on the atmel website, atmel assumes no liability whatsoever and disclaims an y express, implied or statutory warranty relating to its p roducts including, but not limited to, the implied warranty of merchant ability, fitness for a particular purpose, or non-infringement. in no event shall atmel be liable for any direct, indirect , consequential, punitive, special or in cidental damages (including, without limi tation, damages for loss and profits, business interruption, or loss of information) arising out of th e use or inability to use this document, even if atmel has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or c ompleteness of the contents of this document and reserves the right to make c hanges to specifications and products descripti ons at any time without notice. atmel d oes not make any commitment to update the information contained herein. unless specifically pr ovided otherwise, atmel products are not suitable for, and shall not be used in, automo tive applications. atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. safety-critical, military, and automotive applications discla imer: atmel products are not designed for and will not be used in connection with any applications where the failure of such products would reasonabl y be expected to result in significant per sonal injury or death (?safety-critical a pplications?) without an atmel officer's specific written consent. safety-critical applications incl ude, without limitation, life support devices and systems, equipment or systems for t he operation of nuclear fa cilities and weapons systems. atmel products are not designed nor intended for use in military or aerospace applicat ions or environments unless specifically designated by atmel as milit ary-grade. atmel products are not designed nor intended for use in automotive applications unl ess specifically designated by atmel as automotive-grade.


▲Up To Search▲   

 
Price & Availability of ATSAMD20E17

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X